How to compile Linux kernel on Ubuntu?
Following are the steps to compile a kernel source code on ubuntu-
Steps:
-
Change to root : su
-
Update the package manager : apt-get update
-
Get new make utility : apt-get install build-essential
-
Optional - To create dep : apt-get install kernel-package libncurses5-dev fakeroot wget bzip2
-
Download linux source : cd /usr/src
Download patches: v2.6/testing/patch-2.6.27-rc1.bz2
2.6.27-rc1-mm.bz2
-
Then we unpack the kernel sources and create a symlink linux to the kernel sources directory:
tar xvjf linux-2.6.18.1.tar.bz2
ln -s linux-2.6.18.1 linux
cd /usr/src/linux
-
Apply patches:
bzip2 -dc patch-2.6.27-rc1.bz2 | patch -p1
bzip2 -dc 2.6.27-rc1-mm.bz2 | patch -p1
-
Execute : make clean
make mrproper
-
Configure kernel:
Copy already existing config file:
cp /boot/config-`uname -r` ./.config
make menuconfig
Go to Load an Alternate config file. Enter .config and enter. Exit
-
Make kernel: make && make modules_ install && make install
Check if depmod is already not done.
If not done then type: depmod 2.6.27-rc1-mm
-
To use initrd then get yaird:
apt-get install yaird
-
Execute:
mkinitrd.yaird –o /boot/initrd.img-2.6.27-rc1-mm1 2.6.27-rc1-mm1
If this doesn’t work then execute:
mkinitramfs –o /boot/initrd.img-2.6.27-rc1-mm1 2.6.27-rc1-mm1
Update grub (/boot/grub/menu.lst): update-grub
Check the menu.lst file and see the entry of new kernel
-
Reboot