It may seem a bit strange to have a page for "Advanced topics" in a newbiedoc. We know that some of our readers aren't new to Linux or even to building kernels; they are trying to learn The Debian Way to administer their systems. Once you have successfully used kernel-package to build and install your own custom kernel, you may want to explore some ways to make life even better.
When you installed your custom kernel, its configuration was copied to /boot/config-x.y.z. You may want to squirrel it away in another location (or several other locations) for safekeeping or later re-use.
Suppose that just last week you picked your way through the maze of options, and settled on a configuration that supports all the hardware and features you want. Today a new stable kernel is released and of course you want to upgrade right away. Is it necessary to start from scratch configuring the new kernel? Not at all.
Download and expand the new source tarball and make a new symlink. Then change directories to /usr/src/linux, copy your existing configuration there and do "make oldconfig":
bash:/usr/src/linux$ cp /boot/config-2.4.18.030320 .config bash:/usr/src/linux$ make oldconfig |
You'll be asked questions about new kernel options. It's generally safe to answer "no" to all the questions; make notes of the new options that interest you.
After you finish oldconfig you can run xconfig or menuconfig to review your selections, change your answers, or investigate the options you noted. |
Then do "fakeroot make-kpkg clean" and you're ready to build the latest stable kernel with your own configuration.
Although LILO is still Debian's default boot loader, grub is an outstanding alternative, and it works and plays well with make-kpkg.
After you've installed grub, run "grub-install /dev/hda" (substitute your boot device for "/dev/hda"). Then run "update-grub". Edit /boot/grub/menu.lst and substitute your defaults on the "#groot" and "#kopt" lines (and any other lines you need for your situation). Run "update-grub" again.
Create the file /etc/kernel-img.conf and insert the following lines:
postinst_hook=/sbin/update-grub
postrm_hook=/sbin/update-grub
Now whenever you install a new kernel image, update-grub will scan your /boot directory, inventory the kernels there, and write a new boot menu. If you took my suggestion and used "--append-to-version=.yymmdd", your kernels will be sorted by kernel version and date. The grub default is to start the first kernel in the list (your newest kernel), unless you choose a different one before the menu times out. When you remove a kernel, update-grub will remove its entry from the boot menu.
When you're comfortable with grub, do "dpkg -P lilo" and you won't be asked about lilo when you install a new kernel. :) |
"Third-party modules" is the term I use for kernel modules with source code outside the kernel source tree. An example is "pcmcia-cs", which many laptop users need for the latest PCMCIA support.
To use pcmcia-cs, apt-get the "pcmcia-source" package; the source tarball should be in /usr/src. As a normal user, expand the source tarball to /usr/src/modules/pcmcia-cs. If you don't already have a modules directory one will be created.
When you configure your kernel, disable PCMCIA support. (If you have PCMCIA support enabled, pcmcia-cs won't build drivers.) If you want to use wireless LAN, enable it under "Network device support" but don't select any devices.
When you are ready to build your kernel, add "modules_image" to your command line:
bash:/usr/src/linux$ fakeroot make-kpkg --append-to-version=.030401 kernel_image modules_image |
(As you learn more and more the make-kpkg command line gets longer and longer.)
After your kernel-image .deb is made, make-kpkg will go to /usr/src/modules and build a modules .deb for each subdirectory, with the same version and --append-to-version as your kernel. Install the modules-image .debs after you install the kernel-image .deb.
That's it. Could this get any easier?
You've been monitoring the debian-user mailing list, and you notice that more and more people are interested in alsa (Advanced Linux Sound Architecture). You realize that your new sound card doesn't sound as good as it should, and you want to try alsa yourself. You fire up "make menuconfig" (you are more experienced now) but in the "Sound" section you don't see anything labelled "alsa". What to do?
Install the "alsa-source" package. By now you know to look for a new tarball in /usr/src, and there it is:
bash:/usr/src$ ls alsa-driver.tar.bz2 kernel-image-2.4.18.030401_10.00.Custom_i386.deb kernel-source-2.4.18 kernel-source-2.4.18.tar.bz2 modules pcmcia-modules-2.4.18.030401_3.1.33-6+10.00.Custom_i386.deb |
Expand the alsa-driver tarball and re-create the symlink. Note the --append-to-version value of your kernel image; you'll need it as an option for make-kpkg:
bash:/usr/src$ cd linux bash:/usr/src/linux$ fakeroot make-kpkg --append-to-version=.030401 --added-modules=alsa-driver modules_image |
Notice that you don't need the "kernel_image" target here. Unless you reconfigured the kernel, there's no need to rebuild it. Using the "--added-modules" option lets you build only the modules you need, instead of all the modules in /usr/src/modules.
If you want to build a modules .deb with a different --revision than the kernel, you may need to appease make-kpkg by doing "fakeroot make-kpkg clean". |
Debian offers a wide variety of kernel patches, from the leading-edge innovative to the boringly safe. I like boringly safe, so I downloaded kernel-patch-debianlogo.
The debianlogo patch replaces Tux in the upper-left corner of your framebuffer boot console with another nice image. If you don't have a kernel-patches directory it will be created when you install your first kernel-patch package.
The kernel-patches directory is only for Debian kernel-patch packages. If you have other kernel patches they should go somewhere else. |
Installing a kernel-patch package does not apply the patch. That is done by invoking make-kpkg, with the option "--added-patches":
bash:/usr/src/linux$ fakeroot make-kpkg --append-to-version=.030401 --added-patches=debianlogo kernel_image modules_image |
If you have several patches to apply list them after "--added-patches=", separated by commas.
By default make-kpkg runs "make oldconfig" after applying kernel patches. If your patches includes new kernel options, you will be asked about them. If you want to review the entire configuration instead, you can use yet another command-line option, "--config=menuconfig". When you save your configuration and exit menuconfig, make-kpkg will continue.
After the kernel image is built, make-kpkg reverses the patches you applied so that you begin each configure/build cycle with an unpatched source tree.