- Methods and Reasons
- Copying the Knoppix filesystem
- Installing/Upgrading software
Installing/Upgrading software
The apt subsystem is a packaging system designed for Debian that can speed up installing software. Most free software has a Debian package created, so you can save yourself from the "./configure && make && make install" routine. First you'll want to update the apt-database:
root@not a tty[/]# apt-get update
This will connect to the mirrors specified in /etc/apt/sources.list. Add mirrors closer and faster to you if possible, check the http://www.debian.org/mirror/list for more options. This requires a working internet connection on the host system, as well as an accurate /etc/resolv.conf in the chrooted environment (which is likely not configured). Remember that if you change /etc/resolv.conf in the host environment that's the nameserver that will be used on the bootable CD! Remove internal or private nameservers after configuring the system but before releasing it to the public.
Now that the database is updated, install software is as easy as a single command line:
root@not a tty[/]# apt-get install fluxbox
This command line will attempt to install the Fluxbox4 window manager on your system. If the package does not require any additional packages to be installed, it begins on its own. If additional libraries are necessary, you will be asked to confirm their installation. It will even tell you the approximate amount of space required—good to know when you need to keep the Knoppix system as small as possible. Finally, if the package already exists, you will be informed and then given the option of upgrading (if a new package is available). Finding packages to install can be accomplished by:
root@not a tty[/]# apt-cache search fluxbox
which will provide a list of packages with 'fluxbox' in either their name or description. Use the "apt-get install" command once you find the correct full package name. A more exhaustive search and listing can be found at http://www.debian.org/distrib/packages. Knoppix 3.8 is based off Debian 3.1, also known as 'sarge' or 'stable." If you are using another Knoppix distribution, check /etc/debian_version. Finally, you can also upgrade all the currently-installed packages to their most recent version. Be aware that this will take up a lot of precious space though, as the apt subsystem will often upgrade unnecessary software. Be sure to upgrade before you trim the unneeded pieces below, or upgrade case for each package. Individual packages can be upgraded by running "apt-get install packagename."
Removing packages
You will likely spend more effort removing files than installing new ones. Not only does the compressed filesystem need to fit on a 700MB CD, but every bit must later be uncompressed and either kept in RAM or read from the CD. Running from the CD can be slow since the drive needs to spin up and spin down each time, even just to access simple commands. Modern Knoppix versions have a 'toram' option on their bootscreen that can copy the entire CD to RAM—freeing the CD-ROM drive and greatly improving performance. This, of course, requires a system with enough RAM to hold the filesystem—about 1.7GB for the default distribution—so smaller is better. The basic removal command is:
root@not a tty[/]# apt-get --purge remove packagename
The --purge option will remove the configuration files in /etc and elsewhere that are associated with the package, and is recommended. Otherwise sparse configuration files will be left on the filesystem, not necessarily taking up space, but certainly confusing users and possibly breaking re-installations down the road. Getting a list of all installed packages is done through dpkg-query (the dpkg series of commands all operate on the same subsystem as the apt series, as apt series is an abstraction on top of dpkg):
root@not a tty[/]# dpkg -l
or
root@not a tty[/]# dpkg-query -W
To get an idea of the size of each application, use:
root@not a tty[/]# dpkg-query -W --showformat="${InstalledSize} {$Package}" | sort -n
Working with the Knoppix 3.8 CD, we can see that removing OpenOffice alone will free about 245Mb of installed space. Removing KDE, along with all the internationalizations, will save another 250Mb of uncompressed space. Other packages can be removed at your discretion; using apt-get will ask for confirmation before removing anything unintentional and will take care of the dependencies. Removing packages ending in "-dev" is usually a safe bet, if you do not plan on compiling or developing software with your Knoppix disk. Remove unnecessary locales (language information) through the localepurge program. You may have to install this through apt-get. Afterwards, if you decide you need a different selection, edit /etc/locale.gen to reflect your needs and then run:
root@not a tty[/]# locale-gen root@not a tty[/]# localepurge
When you have removed all unnecessary packages, use the deborphan command to locate libraries that are no longer required by any package:
root@not a tty[/]# deborphan | xargs apt-get --yes --purge remove
After configuration is complete, clean the system of loose ends that the apt subsystem may have downloaded:
root@not a tty[/]# apt-get clean
Now is the time to restore any configuration files you changed during this portion, such as /etc/resolv.conf or /etc/apt/sources.list. After the system is precisely as you want it to be for your users, you can begin creating the compressed filesystem.
Staying in the chroot jail, execute the following command (type carefully!):
root@not a tty[/]# mkisofs -R -U -v -V "Knoppix ISO9660 FS" -P "Name of Publisher" -p "Name of Creator" -hide-rr-moved -cache-inodes -no-bak -pad -m /KNOPPIX.build/* / | /usr/bin/create_compressed_fs - 65536 > /KNOPPIX.build/KNOPPIX/KNOPPIX
Note that the argument after -m is a directory/listing that will be ignored and not put into the filesystem. You can use multiple -m directives to prevent other pieces from going into the filesystem, but this one is required or else you will end up adding your build directory into your final filesystem. The argument after it and before the pipe command is the root directory /, from where the mkisofs program will add files. Lastly, the final argument is the output of the entire process, or the compressed filesystem itself. Go grab a cup of coffee, pick up a magazine, or go for a jog. Compressing the filesystem will take quite some time and be memory and processor-intensive on the host system.
Unmount proc and break out of the chrooted environment:
root@not a tty[/]# umount proc root@not a tty[/]# exit (or CTRL-D)
Now, change to the directory where you copied the entire CD-ROM. It should now have the compressed filesystem as well. In our example, this would be /knoppix-cd/KNOPPIX/KNOPPIX.build/. There should be two directories, KNOPPIX and boot. Now you can create the final ISO file. One last mkisofs:
root@tty1[KNOPPIX.build]# mkisofs -pad -l -r -J -V "Knoppix disc" -no-emul-boot -boot-load-size 4 – boot-info-table -b boot/isolinux/isolinux.bin -c boot/isolinux/boot.cat -hide-rr-moved -o knoppix.iso
Once this is complete, burn it with your favorite CD-ROM burning program and you're done. I suggest installing a copy of qemu, a free x86 emulator, similar to VMWare, so that you can test out the ISO before burning a CD. If it is installed it should look like this:
root@tty1[KNOPPIX.build]# qemu -cdrom knoppix.iso
Figure 1 Using Qemu to test an ISO before burning
And you should be able to boot into the CD. Check for any problems thoroughly here and if all is well, move on to creating the physical CD.
In my next article, I will cover the other changes that you can make to your Knoppix CD, including changing the splash screen, upgrading the kernel, and choosing default boot options.
For more information on Linux, visit our Linux Reference Guide or sign up for our Linux Newsletter