One of the more complicated areas of Knoppix remastering, swapping the Linux kernel is not for the faint of heart. There are three ways you can go about exchanging the kernel:
The Debian way, by installing a pre-made kernel
By using make-kpkg to create your own kernel package, which can be installed manually
By manually downloading, configuring, compiling, and installing your kernel
This section discusses the first two; doing everything manually doesn't offer any advantages over using make-kpkg.
The first step in all three processes is removing the installed kernel in the chroot of the KNOPPIX/KNOPPIX file. As with everything in Knoppix, you can easily remove the kernel by using apt-get:
# apt-get remove kernel-image-2.6.12
You get a warning when running this command if your host system is running the same kernel. Because you are removing the kernel from the chroot, you can safely ignore the warning. Type Yes to continue.
You should also remove any existing kernel module packages for the 2.6.12 kernel. They won't function with a different kernel, so keeping them installed doesn't serve any purpose:
# apt-get remove *modules-2.6.12
When replacing the kernel, the most work involves ensuring that all the kernel modules you want are included in your Live CD. Different kernel modules need to be built in different ways, as you'll see later in this chapter.
In Debian, a large number of kernels are available for a variety of systems. The kernels are generic enough to work on as many different machines as possible and are a good bet if you aren't acquainted with configuring and compiling your own kernel. The advantage is that this process is relatively easy to do; the drawbacks are a lack of choice as to which kernels you can use and a lack of control over which kernel module and options are chosen — these already have been chosen for you.
To begin, you have to find the kernel that suites your purposes. Use synaptic to search for kernel image packages (their names start with kernel-image). Say, for instance, that you want to use an older 2.4 Linux kernel; execute the following in the chroot:
# apt-get install kernel-image-2.4.27-2-386
There you have it, your new (albeit old) kernel. Don't think that you're done this quickly, though, because each kernel also needs kernel module packages in order for all functionalities to be available. The following command installs the pcmcia modules, which are required if you want your Live CD to function properly with removable hardware in laptops:
# apt-get install kernel-pcmcia-modules-2.4.27-2-386
If you want to support wireless network cards, install the linux-wlan-ng package:
# apt-get install linux-wlan-ng-modules-2.4.27-2-386
To be able to compile kernel modules that aren't pre-packaged for your kernel, it's a good idea to also install the accompanying kernel-headers package:
# apt-get install kernel-headers-2.4.27-2
If you prefer more control over choices made regarding what kind of kernel goes onto your Live CD, you still can use the flexibility that Debian provides. It's highly recommended that you do this on your host system and save the resulting packages in a separate directory, so that you don't have to worry about losing all your hard work. You'll also be able to make small changes without having to start from scratch.
On your host system, do the following:
# apt-get install kernel-source-2.6.11
This downloads the kernel source from the Debian repository; it ends up in /usr/src. Unpack the source:
# cd /usr/src # tar jxvf kernel-source-2.6.11.tar.bz2
This command extracts the kernel source into /usr/src/kernel-source-2.6.11. Enter that directory:
# cd kernel-source-2.6.11
Now you have two options: use a default configuration supplied by Debian or create your own. If you want to create your own configuration, you can use one of the following commands:
# make menuconfig # make xconfig # make gconfig
All three configuration tools provide an interface in which you can select the various kernel options for the intended systems. You can use the existing Knoppix configuration by loading in the configuration from /usr/src/linux/.config; this is possible in all three configuration tools. Unless your kernel is very different from the existing Knoppix kernel or the intended usage is restricted, it's a good idea to start with the existing Knoppix kernel configuration, so that you only have to tweak the settings for situations in which your usage differs.
After you have configured your kernel, you're ready to create the kernel packages for your Live CD. Execute the following:
# make-kpkg kernel_image
This command starts compiling your new kernel. It takes a while, but afterward four new files are in the /usr/src directory: a kernel-image package, a kernel-source package, a kernel-headers package, and a kernel-doc package. Copy the kernel-image package and kernel-headers packages into your chroot and install them there using dpkg.For example:
# dpkg -i kernel-image-2.6.11_10.00.Custom_i386.deb kernel-headers-2.6.11_10.00.Custom_i386.deb
If everything went well, you have replaced your kernel successfully. Congratulations! However, you aren't out of the woods yet.
There is one kernel module a Knoppix-based Live CD can't function without: the cloop driver. You used the cloop utilities for extracting the /KNOPPIX/KNOPPIX file at the beginning of this chapter, and in a few moments you'll use them to compress it again. For your Live CD to actually use the compressed data, however, the cloop driver has to be on that CD. The cloop package isn't pre-compiled for any kernels, so you have to make your own.
First, make sure you either have the kernel headers installed or the kernel source. If you followed the directions in either of the preceding sections, this should be the case. Now do the following outside of the chroot:
# apt-get install cloop-src
The cloop-src package contains the source you need to compile. It is placed in /usr/src/cloop.tar.gz:
Unpack the cloop source in /usr/src/modules/cloop:
# cd /usr/src # tar zxvf cloop.tar.gz
If you have installed the kernel headers, make sure you have the same kernel headers installed on your host system. Then do the following:
# cd /usr/src/modules/cloop # debian/rules KSRC=/usr/src/ kernel-headers-2.4.27-2 KVERS=2.4.27-2 kdist_image
The package required is built and placed in /usr/src/modules.
Otherwise, use the following if you still have the source of the kernel you made on your host system:
# cd /usr/src/kernel-source-2.6.11 # make-kpkg modules_image
The package required is built and placed in /usr/src.
Now, copy either the cloop-module-2.6.11 or the cloop-module-2.4.27-2 package into the chroot:
# cp ../cloop-module-2.6.11_2.01.5-3_i386.deb /home/ knoppix/knoppixuncompressed/
Inside the chroot, install the package:
# dpkg -i cloop-module-2.6.11_2.01.5-3_i386.deb
If all goes well, your new cloop kernel module exists as /lib/modules/2.6.11/kernel/drivers/block/cloop.ko. Make sure it exists, because you'll need it for the next section.
When booting up, Knoppix first loads a small compressed image into memory. That image is called the initial RAM disk; it contains just enough information (drivers and scripts) to start up the Linux system and hand the boot process off to another set of scripts located elsewhere that are responsible for bringing up services on a machine. Using the files on that image, Knoppix accesses the larger compressed /KNOPPIX/KNOPPIX file. On the ISO, this image is at /boot/isolinux/minirt.gz. To have Knoppix use your updated kernel, you have to update the image file, too, because it contains a number of kernel modules.
Use the following to uncompress the RAM disk:
# cd /home/knoppix/boot/isolinux # gunzip minirt.gz
To access its contents, you have to mount the image:
# mkdir /home/knoppix/minirt # mount -o loop minirt /home/knoppix/minirt # cd /home/knoppix/minirt
Now comes the ugly part. You need to copy quite a few kernel modules, and if you are doing this more than once (which you probably will), you should make a shell script to automate the process. To make matters worse, the directories, names, and extensions of those kernel modules are all hard-coded and in a different location than they normally are. If you are remastering a newer version of Knoppix, check the locations of these modules in the modules/ directory. If you have a different kernel, you check its location in the /home/knoppix/knoppixun compressed/lib/modules/KERNEL_VERSION/kernel/drivers directory, replacing KERNEL_VERSION with the version you are using.
Copy the new/custom kernel modules into the new RAM disk:
# cp /home/knoppix/knoppixuncompressed/lib/modules/2.6.11/lib/ modules/2.6.11/kernel/drivers/block/cloop.ko /home/knoppix/ minirt/modules/cloop.ko # cp /home/knoppix/knoppixuncompressed/lib/modules/2.6.11/lib/ modules/2.6.11/kernel/drivers/scsi/BusLogic.ko /home/ knoppix/minirt/modules/scsi/BusLogic.o # cp /home/knoppix/knoppixuncompressed/lib/modules/2.6.11/lib/ modules/2.6.11/kernel/drivers/scsi/NCR53c406a.ko /home/ knoppix/minirt/modules/scsi/NCR53c406a.o # cp /home/knoppix/knoppixuncompressed/lib/modules/2.6.11/lib/ modules/2.6.11/kernel/drivers/scsi/a100u2w.ko /home/ knoppix/minirt/modules/scsi/a100u2w.o # cp /home/knoppix/knoppixuncompressed/lib/modules/2.6.11/lib/ modules/2.6.11/kernel/drivers/scsi/advansys.ko /home/ knoppix/minirt/modules/scsi/advansys.o # cp /home/knoppix/knoppixuncompressed/lib/modules/2.6.11/lib/ modules/2.6.11/kernel/drivers/scsi/aic7xxx/aic7xxx.ko / home/knoppix/minirt/modules/scsi/aic7xxx.o # cp /home/knoppix/knoppixuncompressed/lib/modules/2.6.11/lib/ modules/2.6.11/kernel/drivers/scsi/dtc.ko /home/knoppix/ minirt/modules/scsi/dtc.o # cp /home/knoppix/knoppixuncompressed/lib/modules/2.6.11/lib/ modules/2.6.11/kernel/drivers/usb/host/ehci-hcd.ko /home/ knoppix/minirt/modules/scsi/ehci-hcd.o # cp /home/knoppix/knoppixuncompressed/lib/modules/2.6.11/lib/ modules/2.6.11/kernel/drivers/scsi/fdomain.ko /home/ knoppix/minirt/modules/scsi/fdomain.o # cp /home/knoppix/knoppixuncompressed/lib/modules/2.6.11/lib/ modules/2.6.11/kernel/drivers/scsi/gdth.ko /home/knoppix/ minirt/modules/scsi/gdth.o # cp /home/knoppix/knoppixuncompressed/lib/modules/2.6.11/lib/ modules/2.6.11/kernel/drivers/scsi/ieee1394/ieee1394.ko / home/knoppix/minirt/modules/scsi/ieee1394.o # cp /home/knoppix/knoppixuncompressed/lib/modules/2.6.11/lib/ modules/2.6.11/kernel/drivers/scsi/initio.ko /home/ knoppix/minirt/modules/scsi/initio.o # cp /home/knoppix/knoppixuncompressed/lib/modules/2.6.11/lib/ modules/2.6.11/kernel/drivers/scsi/mptscsih.ko /home/ knoppix/minirt/modules/scsi/mptscsih.o # cp /home/knoppix/knoppixuncompressed/lib/modules/2.6.11/lib/ modules/2.6.11/kernel/drivers/usb/host/ohci-hcd.ko /home/ knoppix/minirt/modules/scsi/ohci-hcd.o # cp /home/knoppix/knoppixuncompressed/lib/modules/2.6.11/lib/ modules/2.6.11/kernel/drivers/scsi/pas16.ko /home/knoppix/ minirt/modules/scsi/pas16.o # cp /home/knoppix/knoppixuncompressed/lib/modules/2.6.11/lib/ modules/2.6.11/kernel/drivers/scsi/psi240i.ko /home/ knoppix/minirt/modules/scsi/psi240i.o # cp /home/knoppix/knoppixuncompressed/lib/modules/2.6.11/lib/ modules/2.6.11/kernel/drivers/scsi/sbp2.ko /home/knoppix/ minirt/modules/scsi/sbp2.o # cp /home/knoppix/knoppixuncompressed/lib/modules/2.6.11/lib/ modules/2.6.11/kernel/drivers/scsi/seagate.ko /home/ knoppix/minirt/modules/scsi/seagate.o # cp /home/knoppix/knoppixuncompressed/lib/modules/2.6.11/lib/ modules/2.6.11/kernel/drivers/scsi/sym53c8xx_2/ sym53c8xx.ko /home/knoppix/minirt/modules/scsi/sym53c8xx.o # cp /home/knoppix/knoppixuncompressed/lib/modules/2.6.11/lib/ modules/2.6.11/kernel/drivers/scsi/t128.ko /home/knoppix/ minirt/modules/scsi/t128.o # cp /home/knoppix/knoppixuncompressed/lib/modules/2.6.11/lib/ modules/2.6.11/kernel/drivers/scsi/tmscsim.ko /home/ knoppix/minirt/modules/scsi/tscsim.o # cp /home/knoppix/knoppixuncompressed/lib/modules/2.6.11/lib/ modules/2.6.11/kernel/drivers/scsi/u14-34f.ko /home/ knoppix/minirt/modules/scsi/u14-34f.o # cp /home/knoppix/knoppixuncompressed/lib/modules/2.6.11/lib/ modules/2.6.11/kernel/drivers/scsi/ub.ko /home/knoppix/ minirt/modules/scsi/ub.o # cp /home/knoppix/knoppixuncompressed/lib/modules/2.6.11/lib/ modules/2.6.11/kernel/drivers/scsi/ultrastor.ko /home/ knoppix/minirt/modules/scsi/ultrastor.o # cp /home/knoppix/knoppixuncompressed/lib/modules/2.6.11/lib/ modules/2.6.11/kernel/drivers/usb/storage/usb-storage.ko / home/knoppix/minirt/modules/scsi/usb-storage.o # cp /home/knoppix/knoppixuncompressed/lib/modules/2.6.11/lib/ modules/2.6.11/kernel/drivers/usb/host/usb-uhci.ko /home/ knoppix/minirt/modules/scsi/usb-uhci.o # cp /home/knoppix/knoppixuncompressed/lib/modules/2.6.11/lib/ modules/2.6.11/kernel/drivers/core/usbcore.ko /home/ knoppix/minirt/modules/scsi/usbcore.o # cp /home/knoppix/knoppixuncompressed/lib/modules/2.6.11/lib/ modules/2.6.11/kernel/drivers/scsi/wd7000.ko /home/knoppix/ minirt/modules/scsi/wd7000.o
If you make it through all these commands and all goes well, you've now replaced all the kernel modules on the Knoppix RAM disk. You might have noticed that in addition to SCSI and the cloop driver, the USB and FireWire kernel modules were included. All these kernel modules enable your Live CD to also boot from SCSI, USB, and FireWire devices!
Now you can umount the RAM disk and finalize your modifications to your Live CD:
# cd /home/knoppix/knoppixiso/boot/isolinux # umount /home/knoppix/minirt # gzip minirt
The updated RAM disk now resides at /home/knoppix/knoppixiso/boot/isolinux/minirt.gz.
The last step is to replace the actual kernel on your Live CD ISO. Copy it from the /boot directory in your chroot in your knoppixiso directory, overwriting the one previously used to boot Knoppix. For example:
# cp /home/knoppix/knoppixuncompressed/boot/ vmlinuz-2.6.11 /home/knoppix/knoppixiso/boot/isolinux/linux
If you have installed a different kernel, check the /boot directory of your chroot for the correct name; the kernel name will start with vmlinuz and typically have the kernel version appended.
Survived until this point? Everything work as planned? Well done, because you have successfully replaced the Knoppix kernel! If something went wrong retrace your steps: Replacing the Knoppix kernel is an error-prone process and is likely to take a few tries before success is achieved.