|
Custom Linux Kernels with Debian and Fedora
The Debian Way of Customizing KernelsEarlier this week we took a tour of the generic way of building custom Linux kernels. Today we'll look some nice Debian shortcuts, and Fedora's unique way of building custom kernels. The Debian Way of Customizing KernelsDebian's kernel source packages are named
Binary Debian kernel packages are named
To get started, install a build environment (see part 1), plus your kernel sources and the # aptitude install linux-source-2.6.22 kernel-package fakeroot
This downloads the source tarball into # mv /usr/src/linux-source-2.6.22.tar.bz2 ~/kernel Change to your personal kernel-building directory and unpack the tarball: $ tar zxvf linux-source-2.6.22.tar.bz2 Then change to the top-level source directory and start configuring your new kernel: $ cd linux-source-2.6.22 $ make mrproper $ make xconfig When you're done slogging through configuration, run these commands: $ make-kpkg clean $ make-kpkg -rootcmd fakeroot -rev kernel.1 linux_image
# dpkg -i linux-image-2.6.22_kernel.1_i686.deb
This installs the modules and handles module dependencies, creates a boot menu entry, and copies the kernel and related file to the
The Fedora Way of Customizing KernelsFedora patches its kernels all to heck, to the point that a vanilla kernel may not work. Of course it costs nothing but a bit of time to try. But if you want to use genuine Fedora kernel sources they come in source RPMs, so you'll have to build your kernel and then package it into an RPM. First fetch your kernel SRPM from your favorite Fedora mirror, such as: $ wget http://mirrors.kernel.org/fedora/releases/7/Fedora/source/SRPMS/kernel-2.6.21-1.3194.fc7.src.rpm Then make sure you have the RPM building tools, plus the normal build environment from part 1: # yum install rpmdevtools The next step is to create a build tree in your home directory, and make sure to do this as yourself and not as the root user: $ fedora-buildrpmtree
This creates an $ rpm -ivh 2.6.21-1.3194.fc7.src.rpm Ignore the warnings about "group kojibuilder does not exist."
Next, run the $ rpmbuild -bp --target=i686 ~/rpmbuild/SPECS/kernel-2.6.spec This extracts the kernel tarball and applies all the Fedora patches. Now change to the source directory of your new build tree: $ cd ~/rpmbuild/BUILD/kernel-2.6.21/linux-2.6.21-1.3194.i686/ And get started with configuring your new kernel: $ make mrproper $ make xconfig Finally, roll it all up into an RPM: $ rpmbuild --target i686 -ba ~/rpmbuild/SPECS/kernel-2.6.spec
Again, make the # rpm -ivh kernel-2.6.21-1.3194.i686.rpm
This handles all the chores of copying files to
What Kernel Options To Use?
When you open
We'll take a quick tour of necessary and common options, so you're still going to have to make some decisions on your own. Your first decision is in the "Code Maturity Level Options -> Prompt for development and/or incomplete code/drivers (EXPERIMENTAL)." If you want a plain old stable kernel without any wacky stuff, uncheck this. If you want to test new experimental features, then include this. Say no to "Configure standard kernel features (for small systems) (EMBEDDED)." Unless of course you know this is something you want, which means you're probably a kernel developer. Include everything under "Loadable module support." "Processor Type and Features" is where you can make some noticeable performance tweaks. Turn off SMP if you're not running a multi-core or multi-processor machine. Select your CPU type. Select memory support for your amount of physical RAM. Turn off all the laptop stuff if you're not running a laptop. "Block layer" is where you enable support for large disks and files, which means larger than two terabytes. Under "Bus options" turn off PCMCIA guff on systems that are not laptops. Under "Executable File Formats" include everything. Under "Networking" get rid of all the network protocols you're not going to use like Appletalk, Bluetooth, radio, or IPX. On machines that are not routers or firewalls, you can also get rid of routing options and QoS, and even Netfilter/iptables if you really want to go lean. Don't go too crazy wiping out networking options unless you are very sure you do not want them, because you could break some networking feature that you need. Enable "IP: kernel level autoconfiguration (IP_PNP)" for diskless netbooting. If you're configuring a kernel for a routerboard like a Soekris or PC Engines WRAP board you might consider removing support for SATA, SCSI, and PATA drives, since they are not supported on most of these. The rest is reviewing hardware and filesystem support, and cryptography options, plus a few other odds and ends. I recommend supporting all cryptography, which has become an everyday necessity. I probably spend the most time hunting down and getting rid of laptop-related features on desktop systems, or features related to specific laptops such as Dell and Toshiba, and then the dozens of hardware drivers I'll never need. As a general rule you can turn off anything related to generating debugging messages; these are interesting mainly to kernel hackers, and sometimes not even then. Resources
This article originally appeared on Enterprise Networking Planet, a JupiterWeb site.
|