Updating your kernel is important if you want to take advantage of new hardware support or bleeding edge features. Aside from these obvious benefits it also allows you to keep up with security patches, system optimization, and overall stability issues.
The first thing you have to do is emerge the latest gentoo-sources package.
# emerge -u gentoo-sources
The source will now be installed in /usr/src/linux-2.6.27-gentoo-r2. Your specific version will differ from this one of course.
You now need to update the symlink to point to the new sources.
# cd /usr/src # ln -s linux-2.6.27-gentoo-r2 linux
If your kernel is configured to store a copy of its current configuration in /proc/config.gz you can use those choices to start building your new kernel by copying and uncompressing this stored copy.
# zcat /proc/config.gz > /usr/src/linux/.config
If your current kernel doesn’t support this you can copy the configuration file from the old sources.
# cp /usr/src/linux-2.6.27-gentoo-r2/.config /usr/src/linux/.config
Move to the /usr/src/linux directory.
# cd /usr/src/linux
If you upgrade you kernel on a regular basis you can safely run make oldconfig to configure your new kernel options. This will take your old kernel options and walk you through the configuration changes.
# make oldconfig
If its been awhile use make menuconfig instead. This will give you more context when making configuration choices.
# make menuconfig
Once the new kernel is configured it is time to build it as well as any modules you have specified.
# make && make modules_install
If this completes successfully you new kernel image will be placed here: /usr/src/linux-2.6.27-gentoo-r2/arch/x86_64/boot/bzImage.
Copy this image to the /boot directory. You should rename it to differentiate it from past kernels.
# cp /usr/src/linux-2.6.27-gentoo-r2/arch/x86_64/boot/bzImage /boot/kernel-2.6.27-gentoo-r2
Finally in order to use this image you will have to update your bootloader, such as grub, and add a new entry for the kernel image you have just placed in the /boot directory.
Update grub.conf located here: /boot/grub/grub.conf. Keep your old kernel entry until you have verified your new kernel works correctly.
# New Gentoo Kernel title Gentoo Linux 2.6.27-r2 root(hd0,0) kernel /boot/kernel-2.6.27-gentoo-r2 root=/dev/sda0 # old Gentoo Kernel title Gentoo Linux 2.6.27-r1 root(hd0,0) kernel /boot/kernel-2.6.27-gentoo-r1 root=/dev/sda0
To use the new kernel reboot and select this new entry at the bootloader screen.