与红帽企业Linux2.1和3不同,在红帽企业Linux4的发行版中没有提供kernel-source软件包。同时提供一个kernel-source软件包和一个kernel.src.rpm包是多余的。需要使用内核源代码的用户可以使用kernel.src.rpm软件包。
在红帽企业Linux4中,kernel-devel软件包包括了内核的头文件。因此在编译第三方内核模块时不再需要内核源代码的软件包。你可以在一个终端上以root身份使用下面的命令来安装一个kernel-devel软件包
#up2date kernel-devel
为了编译与当前使用的内核版本不同的模块你并不需要一个完全的源代码树。你只需简单地把你的Makefile文件指向/lib/modules/'uname -r'/build,就可以了。更加详细的解释可以在Release Notes中找到。
如果你不是编译一个内核的模块,而是由于某种原因需要内核的源代码,你可以在一个终端上以root身份使用下面的命令来来得到:
# up2date redhat-rpm-config rpm-build # up2date --get-source kernel # rpm -ivh /var/spool/up2date/kernel*.src.rpm # cd /usr/src/redhat/SPECS # rpmbuild -bp --target=i686 kernel-2.6.spec # cp -a /usr/src/redhat/BUILD/kernel-2.6.9/linux-2.6.9 /usr/src # ln -s /usr/src/linux-2.6.9 /usr/src/linux 注:这样将会建立一个基于x86架构的源代码树。对于不同的平台(比如x86_64),需要传递适当的参数(比如: rpmbuild -bp --target=x86_64 kernel-2.6.spec)
一旦完成,一个指向最新的2.6内核的源代码树的链接就产生了:
# ls -lt /usr/src total 28 lrwxrwxrwx 1 root root 12 Mar 2 16:36 linux -> linux-2.6.9/ drwxr-xr-x 20 root root 4096 Mar 2 16:21 linux-2.6.9 这些步骤在红帽企业Linux 4的发行注释中也可以得到: http://www.redhat.com/docs/manuals/enterprise/RHEL-4-Manual/release-notes/as-x86/