All of the source code for the Linux Kernel can be found in kernel.org, a worldwide network of servers that mirror the Linux source code. The main http://www.kernel.org site also shows all of the current kernel versions.
First download the latest stable kernel version (Linux-3.11.1) into your home directory.
$ curl -k https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.11.3.tar.xz -o linux-3.11.3.tar.xz
Create a local directory in your home dir called linux and extract the kernel:
$ mkdir ~/linux $ mv linux-3.11.3.tar.xz linux/ $ cd linux; tar -xzvf linux-3.11.3.tar.xz $ ls
Make sure you have gcc, make installed.
Create a .config file in the top directory of the kernel source tree (if there is not one).
$ cd linux-3.11.1 $ ls .config ls: .config: no such file or directory $ make defconfig # Note you can also use "make config" command to create a .config file, but you will be asked by the kernel configuration program if you wish to enable the # option for each configuration or not, and there are almost two thousand different configuration options so it will take a very long time. "make defcofnig" is # just a easy way to create a .config file based on a pre-built configuration. Or you can use the existing kernel configuration file from /boot directory, just do # cp /boot/config-YOUR-CURRENT-KERNEL-VERSION ./.config # There aer also console/graphical configuration methods: $ make menuconfig or $ make xconfig
Building the kernel:
$ makeRunning make causes the kernel build system to use the configuration you have selected to build a kernel and all modules needed to support that configuration.
If you have multiprocessor, you can use the "-j#" option, "#" is twice the number of processors you have, for example:
$ make -j4 - for two processors present
You can also build only a portion of the kernel:
For example, to build the files in the drivers/usb/serial directory, enter:
$ make drivers/usb/serial and $ make M=drivers/usb/serialwill build all the needed files in that directory and link the final module
images.
Install kernel:
Install modules:
# make modules_install
Install kernel:
# make install
After the installation, in your /boot directory, you can see the following newly generated files:
System.map-3.11.3, vmlinuz-3.11.3, initramfs-3.11.3.img and config-3.11.3.x86_64
Also in your /boot/grub/grub.conf file, you can see an new entry has been added:
title CentOS (3.11.3) root (hd0,0) kernel /vmlinuz-3.11.3 ro root=/dev/mapper/vg_tonypc-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_LVM_LV=vg_tonypc/lv_swap rd_NO_MD rd_LVM_LV=vg_tonypc/lv_root SYSFONT=latarcyrheb-sun16 crashkernel=128M KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM initrd /initramfs-3.11.3.img
Reboot your PC and enjoy your new kernel! :)
No comments:
Post a Comment