Installing a new kernel

From Linux 101, The beginner's guide to all things Linux.

Jump to: navigation, search

[edit] Compiling a new Kernel

Navigate to your /usr/src directory and go into the directory of the kernel you want to install. This assumes two things: that you have kernel sources to compile, and that you've grokked Linux kernel configuration.

Run these two commands to produce your kernel:

# make menuconfig
# make

[edit] Copy Files to /boot

On most installations the /boot directory resides on a separate partition. On some systems the /boot partition is not normally mounted so it needs to be mounted before any changes can be made.

# mount /boot

Now the pertinent files need to be copied over to the /boot partition. After compiling a new kernel you'll at least have a System.map file and a bzImage file. Often you'll have a .config file too which you might want to save. .config contains the configuration setting you set when you ran menuconfig. When the files are moved over to /boot they need to go there alongside the old kernel images so add a specific identifier to the file name so you can differentiate them in your bootloader.

# cp System.map /boot/System.map<identifier>
# cp ./arch/i386/boot/bzImage /boot/bzImage<identifier>
# cp .config /boot/config<identifier>


[edit] Change Your Bootloader

Depending on your architecture you'll want to read one of these:

LILO Bootloader

GRUB Bootloader

The important thing to remember when doing this is to not get rid of your older working kernel. Your boot partition can usually hold upwards of five kernel images and there's no good reason why it shouldn't since you'll never know what you might leave out of one kernel that was supported in an older one.

For instance: I once compiled a kernel with support for only ReiserFS and JFS. When I later tried to install a new kernel I found that the kernel I was running did not have support for the ext3 filesystem which my /boot directory was formatted in and so I could not access it. You'll forget plenty of interesting things along the way which is why it's a good idea to hold on to older kernel images and the .config files that came with them.

Personal tools