Compiling and Installing Custom Linux Kernel

Compiling and Installing Custom Linux Kernel
The below mentioned steps will work in Ubuntu or debian like systems. I have tested it on Ubuntu 10.10.
Download and unzip(preparing)
sudo apt-get update
sudo apt-get install kernel-package libncurses5-dev fakeroot wget bzip2
Download the kernel sources and unzip as shown below.
sudo tar xjf linux- ln -s linux- linuxsudo cd /usr/src/linux

Configuring the Kernel
sudo cp /boot/config-`uname -r` ./.config
sudo make menuconfig
Then browse through the kernel configuration menu and make your choices. When you are finished and select Exit, answer the following question (Do you wish to save your new kernel configuration?) with Yes:
Build the Kernel
sudo make-kpkg cleansudo fakeroot make-kpkg –initrd –append-to-version=-custom_1.0 kernel_image kernel_headers
After –append-to-version= you can write any string that helps you identify the kernel, but it must begin with a minus (-) and must not contain whitespace.
Now be patient, the kernel compilation can take some hours, depending on your kernel configuration and your processor speed.
Install the new Kernel
sudo cd /usr/srcsudo ls -l
This will list the kernel files if everything was fine.
Install them like this:
sudo dpkg -i sudo dpkg -i
Now reboot the system
sudo shutdown -r now
If everything goes well, it should come up with the new kernel. You can check if it’s really using your new kernel by running
sudo uname -r

Unistalling the Kernel
Remove files
  1. /boot/vmlinuz*KERNEL-VERSION*
  2. /boot/initrd*KERNEL-VERSION*
  3. /boot/System-map*KERNEL-VERSION*
  4. /boot/config-*KERNEL-VERSION*
  5. /lib/modules/*KERNEL-VERSION*/
  6. /var/lib/initramfs-tools/
Run the command
sudo update-initramfs -k all -u

Leave a Reply