How to Compile the Linux Kernel
Download the latest version of the Linux kernel from http://www.kernel.org., Be sure to download the full source by clicking on the "F" where it says "The latest stable version is..." otherwise you'll just download the patch, which is used when your...
Step-by-Step Guide
-
Step 1: Download the latest version of the Linux kernel from http://www.kernel.org.
An example of this would be
3.4.4.1>>3.4.4.2 ,,, Use these commands. tar xjvf kernel (Here
-j option is for bz2 compression) ,, There are 4 common ways to do this.
Make old configuration
-- asks you questions on what the kernel should support one by one, very time consuming.
Make menuconfig
-- creates a menu where you can browse options on what the kernel supports.
Requires curses library, but that is likely already on your computer.
Make qconfig/xconfig/gconfig
-- same as menuconfig, except that now the configuration menu is graphics based."qconfig" Requires the QT library.
Use configuration of current kernel.
Run this from your kernel source folder "cp /boot/config-`uname
-r` .config".
This saves a lot of time, but you may want to change version number of the to be compiled kernel to avoid replacing your current kernel. "General setup"
--> "Local version
- append to kernel release".
Example if the kernel version number is
3.13.0, you can example write there
3.13.0.RC1. , Further, you may customize the options like adding support for your specific type of device/controller/driver like you may add support for NTFS file system from "Filesystem >> DOS/FAT/NT/ >> select NTFS file system support, thereby taking full advantage of custom kernel. , If you want to use it then you may add further options, otherwise you may disable the option "kernel debugging"
as it makes the kernel a lot heavier and and may be improper to use in the production environment. , You can run needed commands in one line by separating them with double ampersands (&&) as written below.
This may take a long time. make && make modules_install && make install You may want to use
-j option with make.
This allows to fork additional processes for compiling kernel, syntax would be "make
-j 3". 3 here represents the number of processes to be created. ,,,, Use the tool that came with your distro to configure your bootloader.
Add a new entry for the new kernel. , -
Step 2: Be sure to download the full source by clicking on the "F" where it says "The latest stable version is..." otherwise you'll just download the patch
-
Step 3: which is used when your current kernel is a patch number lower.
-
Step 4: Make sure you have downloaded the complete source code
-
Step 5: and not a patch or change log.
-
Step 6: Once downloaded
-
Step 7: open a terminal.
-
Step 8: Now we need to extract the kernel.
-
Step 9: Once extracted
-
Step 10: move into the directory (in the terminal) that was created.
-
Step 11: Configure the kernel.
-
Step 12: Once the configuration window is opened
-
Step 13: you will see that a specific type of configuration is already selected like support for essential drivers like Broadcom wireless support/EXT4 filesystem etc.
-
Step 14: NOTE: While configuring the kernel
-
Step 15: you will see a section known as kernel hacking(by hacking we mean exploring into it)
-
Step 16: where different types of options are given for hacking into kernel and learning it.
-
Step 17: Once configured
-
Step 18: it is time to compile and install the kernel.
-
Step 19: So the kernel is installed
-
Step 20: but you need to make it bootable.
-
Step 21: Go to boot.
-
Step 22: Run this command "mkinitrd -o initrd.img-<kernelversion> <kernelversion>" (For Redhat based distros
-
Step 23: you need not create initrd
-
Step 24: as it is created by default) remembering to replace <kernelverison> with the version number of the kernel you build.
-
Step 25: Point the boot loader at the new kernel so it can be started.
-
Step 26: Reboot and enjoy your customized kernel!
Detailed Guide
An example of this would be
3.4.4.1>>3.4.4.2 ,,, Use these commands. tar xjvf kernel (Here
-j option is for bz2 compression) ,, There are 4 common ways to do this.
Make old configuration
-- asks you questions on what the kernel should support one by one, very time consuming.
Make menuconfig
-- creates a menu where you can browse options on what the kernel supports.
Requires curses library, but that is likely already on your computer.
Make qconfig/xconfig/gconfig
-- same as menuconfig, except that now the configuration menu is graphics based."qconfig" Requires the QT library.
Use configuration of current kernel.
Run this from your kernel source folder "cp /boot/config-`uname
-r` .config".
This saves a lot of time, but you may want to change version number of the to be compiled kernel to avoid replacing your current kernel. "General setup"
--> "Local version
- append to kernel release".
Example if the kernel version number is
3.13.0, you can example write there
3.13.0.RC1. , Further, you may customize the options like adding support for your specific type of device/controller/driver like you may add support for NTFS file system from "Filesystem >> DOS/FAT/NT/ >> select NTFS file system support, thereby taking full advantage of custom kernel. , If you want to use it then you may add further options, otherwise you may disable the option "kernel debugging"
as it makes the kernel a lot heavier and and may be improper to use in the production environment. , You can run needed commands in one line by separating them with double ampersands (&&) as written below.
This may take a long time. make && make modules_install && make install You may want to use
-j option with make.
This allows to fork additional processes for compiling kernel, syntax would be "make
-j 3". 3 here represents the number of processes to be created. ,,,, Use the tool that came with your distro to configure your bootloader.
Add a new entry for the new kernel. ,
About the Author
Sarah Myers
With a background in lifestyle and practical guides, Sarah Myers brings 11 years of hands-on experience to every article. Sarah believes in making complex topics accessible to everyone.
Rate This Guide
How helpful was this guide? Click to rate: