Recompile the Gentoo Linux Kernel

Here I needed to add a few features to my current Kernel.

The first thing I did was take a backup of both the Kernel image, the initramfs image, and the make configuration file (/usr/src/Linux/.config). Then, if everything spectacularly fails, I just need to boot into the live CD and restore the files.

Backup Existing Boot Images

It’s probably wise to backup your .config file if nothing else. I mount an NFS share and then copy the images there.

Make your Changes

While still in the /usr/src/linux directory, type make menuconfig.

storm linux # make menuconfig

I made the following changes.

    General setup  --->
[*] Enable loadable module support  --->
-*- Enable the block layer  --->
    Processor type and features  --->
    Power management and ACPI options  --->
    Bus options (PCI etc.)  --->
    Executable file formats / Emulations  --->
-*- Networking support  --->
    Device Drivers  --->
    Firmware Drivers  --->
    File systems  --->
    Kernel hacking  --->
    Security options  --->
-*- Cryptographic API  --->
[*] Virtualization  --->
    Library routines  --->
---
    Load an Alternate Configuration File
    Save an Alternate Configuration File

I added better support for my i7 processor.

Processor type and features  --->
    Processor family (Generic-x86-64)  --->
        (X) Core 2/newer Xeon 
    [*] MTRR (Memory Type Range Register) support

Then I made the following changes. Note, I had to remove everything under Support for framebuffer devices.

Device Drivers  --->
    [*] Network device support --->
         Bonding driver support
    <*> Connector - unified userspace <-> kernelspace linker  --->
    Graphics support  --->
        <*> Direct Rendering Manager (XFree86 4.1.0 and higher DRI support) --->
        -*- Support for frame buffer devices  --->
            [ ]   Enable firmware EDID
            < >   VESA VGA graphics support
            < >   EFI-based Framebuffer Support
    Input device support --->
        <*> Event interface

Exit and save.

Maybe backup the new .config file too.

Compile the Kernel

If needed, run the below commands to generate dependency information and remove old binaries.

Make sure you’re still within the /usr/src/linux/ directory.

make dep; make clean

And then compile the kernel.

make && make modules_install

Once finished, copy the compiled image to the /boot directory. Don’t forget to mount it first if needed.

mount /boot
cp -v arch/x86_64/boot/bzImage /boot/kernel-3.8.13-gentoo

Rebuilt initramfs Image and Grub Configuration

genkernel --lvm --mdadm initramfs
grub2-mkconfig -o /boot/grub2/grub.cfg
reboot

Resources

Gentoo.org – 7. Configuring the Kernel
http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=1&chap=7

Gentoo.org – Compiling the Linux kernel
http://www.gentoo.org/doc/en/articles/linux-kernel-compiling.xml

Gentoo.org – Baselayout and OpenRC Migration Guide
http://www.gentoo.org/doc/en/openrc-migration.xml

Be the first to comment

Leave a Reply