Building Your Own Linux Kernel, part 2 - page 2
Configuring a New Linux KernelMost kernel configuration options can take one of three states: built-in (*), not built ( ), or module (M). If you're not sure whether you'll buy that Wacom tablet, or you might not have it plugged in all the time, you can build the Wacom driver as a module and it will only be loaded when it's needed.
Sounds great, right? Why not just build everything as modules? That's what the distro kernels do: type lsmod | wc -l to see how many modules you have loaded. But there are disadvantages. The biggest one is speed: each loaded module adds up to half a second to your boot time.
... Well, at least in theory. But once you actually start trying it, you'll find that a lot of them won't let you change 'm' to 'y'. If an option depends on another module, you have to find the dependency and unmark it first.
That's easier said than done. So instead, turn off the second option on the top-level screen, Enable loadable module support (Figure 5). You can always turn it back on later -- but turning it off temporarily will flip all those "M"s to "Y" and take care of your dependency issues.
Pull up a comfy chair -- kernel configuration can take several hours. The kernel has a lot of options, and if you're trying to slim it down, your best bet is to go through all of them, saying "n" to options you don't need and "y" (rather than "m") to most of what you do.
How do you know which options you need? That's always a challenge, and the Help may not always help much (Figure 6).
If a driver was previously set to 'M' and you can find out what its module name is (try the help), lsmod | grep modulename can tell you if you're currently using it. If not, you don't need it.
If you're not sure, see if the help gives you a hint, like "Say N if unsure". Otherwise, it's usually safe to choose the default or stick with the setting your distro kernel used.
A few important options
Remember in Part I where you had to find the .config file for the distro kernel you were previously running? Under General setup, "Kernel .config support" can create a file named /proc/config.gz containing your kernel options. Enable it: you'll appreciate it when you build your next kernel.
Make sure "Remove sysfs features which may confuse old userspace tools" is OFF if you're using a very recent release, like the new Ubuntu 9.10 beta. It will confuse udev and some devices may not work right.
Under Processor type and features, take note of the category labeled "High Memory Support --->". The options are off, 4GB and 64GB. But it's really a trick question. On a modern machine with more than 3GB RAM, you need to set High Memory Support to 64GB, not 4GB, in order to see all 4GB. This has to do with the Physical Address Extension or "PAE", which the kernel won't let you enable unless High Memory is set to 64GB -- but the High Memory help doesn't tell you that. Some distros, such as Ubuntu, use the wrong setting, and can only see 3GB.
When you've finally finished configuring and building, you may need to update the /boot/grub/menu.lst entry for your new kernel. Be sure to make a new entry -- don't overwrite your existing one. It may take a few tries before your new kernel works fully.
If you built without modules, you can comment out the initrd line: you no longer need it. However, if your root device is set to something like root=UUID=cf8ea122-33c9-4745-ae77-18025c53def4, change it to point to the actual root device, e.g. root=/dev/sda2.
If you are using modules, then you may still need an initrd. If you want to make your own rather than re-using the one from your distro, look into mkinitramfs.
Beyond that, you're on your own. Stepping through all the drivers will take a long time -- but when you're done, you'll have a much smaller, faster kernel customized for your own machine, as well as a better understanding of the kernel.
Come back for part 3, in which we will go into more detail on configuration options.
Solid state disks (SSDs) made a splash in consumer technology, and now the technology has its eyes on the enterprise storage market. Download this eBook to see what SSDs can do for your infrastructure and review the pros and cons of this potentially game-changing storage technology.
- 1Linux Top 3: Ubuntu 14.04, Debian Gives Squeeze More Life and Red Hat Goes Atomic
- 2Linux Top 3: CoreOS, Oracle Enterprise Linux 7 and Ubuntu 14.10
- 3Linux Top 3: Debian Dumps SPARC, Ubuntu Takes Over Linux 3.13 and the Core Infrastructure Initiative
- 4Linux Top 3: Fedora, Ubuntu and Gluster Lose Community Leaders
- 5Red Hat Enterprise Linux 7 Finally Hits the Big Time