First, visit http://www.kernel.org/ to pick the kernel you need.
The current latest mainline is at: http://www.kernel.org/pub/linux/kernel/v3.0/testing/linux-3.6-rc7.tar.bz2
The latest stable is at: http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.5.4.tar.bz2
The official site offers both bz2 and xz packages for download.
You can download it with any download tool — for example, I use wget. Extract with tar -xjvf linux* (use -xJvf for the xz package).
It's customary to move the source code into the /usr/src/kernels/ directory.
Then enter the source tree.
If this isn't a fresh install (for instance, the tree was copied from somewhere else, or a previous install attempt failed), be sure to clean up any traces of the earlier build first.
make mrproper #清除环境变量,即清除配置文件
make clean #清除以前编译出的文件
make dep #清除依赖To make kernel configuration easier, copy the config file from the boot directory into your own directory as the .config file.
#cp /boot/config-* /usr/src/kernels/linux-*/.configNcurses is a handy kernel configuration tool that can be installed directly via yum.
yum install ncurses-develThen configure:
make menuconfigA text-based GUI pops up — scroll all the way to the bottom and check "Load an Alternate Configuration". In the dialog that appears, the default .config file is naturally already selected. After confirming, the previous configuration is loaded into Ncurses.
You can then look through it to see if there's anything you want to tweak, and then save.
Now let's actually start compiling:
make bzImage #生成内核文件
make modules #编译模块
make modules_install #安装模块
make install #安装If the compilation completes without errors, you'll see a new set of kernel files added under the /boot directory.
In most cases, Linux uses something like grub/grub2 to manage boot entries, so you can use grub directly to check whether things went through. The commands are:
grub-mkconfggrub2-mkconfggrub-mkconfig -o /boot/grub/grub.confWhen you reboot, the boot menu should show the new kernel as the first entry.
By the way,
rpm -qa | grep kernelReferences:
- Upgrading the kernel on CentOS: http://liaozy.blog.51cto.com/921527/553921
- Steps and methods for upgrading the kernel on CentOS 6.0: http://www.cnblogs.com/zhunian/archive/2012/04/04/2431883.html(This article has been copied all over the internet, so I'm not sure which one is the original; I'm only citing the version I referenced)
Comments
No comments yet — be the first to write one.