Wednesday, October 17, 2007

Compile and Install a New Linux Kernel

Download the latest kernel from www.kernel.org

#wget http://www.kernel.org/pub/linux/kernel/v2.4/linux-2.4.19.tar.gz

#tar zxvf linux-2.4.19.tar.gz

#cd linux-2.4.19

Now you have to configure the kernel options
This is place where you select all the features you want to compile into the kernel. If you have an existing configuration from the older kernel, copy the old .config file to the top level of your source and use make oldconfig instead of menuconfig. This oldconfig process will carry over your previous settings and prompt you if, there are new features not covered by the earlier .config file.
We will presently follow a technique whereby we are just Compiling and Installing a new Kernel.

#make menuconfig

Now you will have to build all the dependencies for your chosen configuration.

#make dep

Now we can compile the actual Kernel

#make bzImage

The resulting kernel file is : arch/i386/boot/bzImage

Now you have to load the modules

#make modules

Install the modules

#make modules_install

Due to some reason you want to re-compile the whole kernel once again. You can use make command to delete intermediate file.
make mrproper command will delete he .config file

Task are as follows:

make mrproper
make menuconfig
make dep
make clean
make bzImage
make modules
make modules_install

Once the task is completed, now we have to boot from the new kernel. I take into consideration that LILO is installed in boot sector.

Before changing its better practice to take a backup

#cp arch/i386/boot/bzImage/vmlinuz-2.4.19

#cp system.map /boot

Now once the above mentioned steps are done we can tell the LILO about the new kernel

Edit the following lilo.conf file

#vi /etc/lilo.conf

image=/boot/vmlinuz-2.4.19
label="Linux 2.4.19"

:wq!

To apply the changes and boot from the new kernel

# lilo -v

Reboot the server.

No comments: