Redhat enterprise Linux / CentOS installing kernel source code
Q. How do I install Linux kernel source code and headers under RHEL 5 or CentOS 5 Linux operating system?
A. Both CentOS and RHEL 5 includes following packages:
a) Kernel-headers : It includes the C header files that specify the interface between the Linux kernel and userspace libraries and programs. The header files define structures and constants that are needed for building most standard programs and are also needed for rebuilding the glibc package.
b) kernel-devel : This package provides kernel headers and makefiles sufficient to build modules against the kernel package.
c) Actual kernel source code : You can always download actual source code here. Look for kernel*.rpm file.
Rhel / CentOS 5 install kernel headers
Use yum command as follows:
# yum install kernel-devel Kernel-headers
Install kernel source code
Type the command as follows:
# cd /tmp
# wget ftp://ftp.redhat.com/pub/redhat/linux/enterprise/5Server/en/os/SRPMS/kernel-2.6.18-8.1.8.el5.src.rpm
# rpm -ivh kernel-2.6.18-8.1.8.el5.src.rpm
Note change version number as per your current kernel.
For recompiling or adding a new module or device driver you just need kernel-devel and Kernel-headers packages. To rebuilt kernel rpm goto /usr/src/redhat/SPECS directory, modify kernel spec file and use rpmbuild command to rebuild rhel/centos kernel rpm.
Subscribe to our free e-mail newsletter or RSS feed to get all updates.
You can Email this page to a friend.
Related Linux / UNIX FAQ:
- You need to have the Linux kernel source installed for this driver
- How do I upgrade the kernel in Linux without compiling from source code?
- Linux turn on kernel preemption
- Patch and Update Redhat Enterprise Linux / CentOS 5 server
- Upgrade Linux kernel howto
Discussion on This FAQ
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Please do not use the comment form to ask for help / question. Ask your question on the excellent Linux tech support forum. Thank you very much for stopping by our site!
Tags: CentOS, c_header_files, devel, glibc_package, kernel_package, kernel_rpm, kernel_source_code, linux_kernel, linux_operating_system, package_c, rhel_5, rpmbuild_command, source_code_type ~ Last updated on: August 20, 2007



September 24th, 2007 at 8:44 pm
The various source rpm’s referenced in the article such as kernel-2.6.18-8.1.8.el5.src.rpm do not contain the source but rather patches to the source…
September 24th, 2007 at 10:07 pm
Upon further examination, the *.src.rpm does have the source in a tarball within it. You’re expected to build the source tree with the rpmbuild command. A command reference would be http://kbase.redhat.com/faq/FAQ_85_5109.shtm
Keep in mind that you will need the unifdef package which is not installed by default. You’ll find it on the third installation CD.