Fedora custom kernels

From Strugglers
Jump to: navigation, search

This article describes how to make a custom kernel on Fedora Linux using the packaged kernel source provided by Fedora themselves. This is based on Fedora Core 3 but the process will be similar for newer releases.

Install the kernel source

  • Download latest kernel SRPM (source RPM) from Fedora 3 Updates (or a local mirror)
  • Install it:
$ sudo rpm -ivh kernel-2.6.12-1.1381_FC3.src.rpm
$ sudo rpmbuild -bp --target=noarch /usr/src/redhat/SPECS/kernel-2.6.spec

You will find the source has been unpacked to /usr/src/redhat/BUILD/kernel-2.6.12

Update old config

$ cd /usr/src/redhat/BUILD/kernel-2.6.12/linux-2.6.12
$ sudo cp /boot/config-2.6.10-prep .config
$ sudo make oldconfig

If you need to alter your config at all:

$ sudo make menuconfig

Generate binary RPM of kernel and modules

$ sudo make rpm

This will generate source and binary RPMs and tell you where it put them.

Install kernel RPM

$ sudo rpm -ivh /usr/src/redhat/RPMS/i386/kernel-2.6.12prep-1.i386.rpm

Generate an initrd if necessary

I hate initrds and avoid them wherever possible. I made the mistake of putting becks's root filesystem in LVM though, so it needs an initrd.

$ cd /boot
$ sudo mkinitrd -v --builtin=sata_nv initrd-2.6.12-prep.img 2.6.12-prep

sata_nv is marked as builtin as it's now part of my kernel. Not sure why I have to specify this and I'm not investigating it because I loathe initrds like nothing on earth and will rebuild becks to not need one before I waste any time on that.

Finishing up

  • Put the usual stanza into /boot/grub/menu.lst being careful that the default kernel is an old known-working one
  • Reboot
  • If everything went well, remove the old kernel(s)