Linux DevCenter    
 Published on Linux DevCenter (
 See this if you're having trouble printing code examples

Using and Customizing Knoppix

by Robert Bernier

Author's note: This following article is no longer completely acurate in that the implementation of the KNOPPIX distribution's boot process has changed since this article was originally written, although the information for the most part is still accurate.

Please email me at If you would like to see an updated article on mastering a KNOPPIX distribution.

Before I get into the guts of my article, I want to start out by sharing a couple of horror stories. My ISP's technician introduced me to Linux. (In those days, I paid $400 for a one-year subscription of 30 hours each month on a dialup 14.4 modem.) I'm thankful for that chance encounter, but learning Linux was, for a long time, an adventure in self-inflicted torture. I'm embarrassed to say it now, but I was grateful that I had Win 3.1 as an alternate to my Linux OS.

Years later, one of the local colleges was preparing a Linux course. We had a classroom filled with computers at our disposal, but were not allowed to install Linux onto them -- instead, we were instructed to use diskettes to load the OS into console mode only. In addition, we had to remove all remnants of Linux from the machines after each and every class.

What do these snapshots of my past have in common? They both highlight the need for a Linux implementation that can be adapted to situations that are highly volatile, politically as well as technically. These days, people are making money using Linux. We install Linux on servers, embedded devices, and kiosks. It is a development environment; think Hollywood, folks. Linux is used as a turnkey solution recovering data from compromised systems and, dare I say, it is even moving up the corporate ladder of workstation usage. To accomplish all of this, the Linux practitioner must be adaptable and possess a talent for improvisation (that, in extreme cases, can be characterized as cowboy-like). These days he is expected to do the job fast and do it right the first time. Enter the live-CD!

The Linux Live-CD

A Linux live-CD distribution is a Linux OS that resides on a CD. It boots and autoconfigures itself without user interaction. Hardware-wise, the CD drive must be the primary boot device, and the machine needs lots of RAM. The autoconfiguration process not only correctly identifies the hardware but selects the best configuration options for the hardware it finds. Take a look at the Linux distributions. You'll notice that several are self-booting; most of these distributions are in fact based on one key distribution, the Knoppix live-CD.

Related Reading

Linux Web Server CD Bookshelf, Version 2.0
6 Bestselling Books on CD-ROM
By A publication of O'Reilly Media

Klaus Knopper created Knoppix. Though this distribution is rather young, it stands out for its hardware detection and autoconfiguration abilities. The packages and OS structure are based on the Debian distribution, but the hardware-discovery process uses kudzu, Redhat's hardware probing utility.

Hardware Requirements

Knoppix has fairly standard hardware requirements. It needs an Intel-compatible CPU (i486 or later) and 20MB of RAM for text mode, with at least 96MB for graphics mode with KDE. 128MB of RAM is recommended when using applications as resource-hungry as As you'd expect, it requires a bootable CD-ROM drive, or a boot floppy and standard drive CD-ROM (IDE/ATAPI or SCSI). Finally, it also requires a standard SVGA-compatible graphics card and a serial, PS/2 standard, or IMPS/2-compatible USB mouse.

How It Works

The boot process resembles a standard CD distribution, but uses virtual drives in RAM. It can boot into either text or graphics mode, requiring more memory in the latter. The OS file system is a single, compressed, read-only file that uncompresses applications and utilities as required. The rest of the CD contains documentation and the boot kernel. Boot time can be anywhere from 30 seconds to two minutes, depending on your hardware.

The CD's bootloader offers you the opportunity to add kernel commands. These "cheat codes" control everything from device discovery to desktops and local language selection. You can view the options yourself by pressing F2 at boot-up time. The default booting process chooses a KDE GUI desktop environment. As the boot process continues, it creates the RAM disk, which is followed by the "hotplug" autoconfiguration process. Shell scripts automatically put in the correct settings for the services once the hardware has been identified. I was pleasantly surprised to see the ease in which my first attempt acquired an IP address from the DHCP server and had put itself on the LAN, ready to go.

Accessing 2GB of binaries from a 700MB CD is a neat trick. You'll find everything from desktops including KDE and GNOME; development tools such as gcc, kdevelop, and libraries; office suites such as, KOffice, and AbiWord; multimedia applications such as the Gimp; network and system administration tools such as tcpdump and ethereal; services such as SMTP, POP, FTP, HTTP, news, DNS, and SSH; and even games such as Frozen Bubble. There are, of course, utilities permitting you to access the Internet via Ethernet, dialup, and PPPoE. There is only one user account, called knoppix. However, the root account is automatically available on the console terminals which can be reached pressing the CTRL-ALT-F3 buttons.

Customizing the Knoppix CD (Making Your own Self-Booting CD!)

Being Linux, the real trick is customizing the Knoppix CD for your own needs.

The Need

The following instructions outline a method to setup a Knoppix-based CD development environment. I've used this setup to complete a CD that will be included in an upcoming book on PostgreSQL. Because the book covers a whole gamut of database concepts from SQL basics to normalization and entity relationship diagrams, the reader needs to be able to see real examples with properly indexed references at the click of a mouse. He shouldn't have to delve into server compilation and configuration just to see how a SQL query works.

As the reader explores the business theory of database design — how a business and the services it provides determines the structure of a database — he should have working examples to explore and experiment with. Having a working server on an OS that doesn't require user configuration overcomes one traditional challenge when writing for Microsoft, Apple, and Unix DBAs in the same book.

One Way to Bake a Cake

The basic idea of making a Knoppix CD is to gather what you want on the CD by simulating it on the hard drive. You should be able to edit installed software and test your creation by rebooting the machine from the hard drive, via a bootloader, instead of wasting time burning it to a CD. This development environment mimics the CD, except it's significantly faster. Remember, this is not a standard Linux installation! Even though you are booting from the hard drive, you are in fact emulating an OS that is installed on a CD. When booted, the filesystem cannot be changed; it is read-only.

Your Required Knowledge Base

You will need the following skills to customize the Knoppix Linux Live-CD:

The Ingredients

You will need the following ingredients to bake your CD:

The Method

First, make sure you back up all of your data before starting. You'll need root access to your machine.

Part 1. Emulating the CD on the hard drive

Step 1: Create a partition

Create an empty Linux partition of at least 700MB. In my case, I chose to resize and format an existing partition on my second hard drive.

Step 2: Create the directory structure

  1. Mount the newly created partition and create a directory named hardrive_boot.

  2. Insert the Knoppix CD and, as root, copy the /KNOPPIX directory from the CD into the root directory of the partition.

  3. Copy the following files from the CD to the root partition: autorun.bat, cdrom.ico, autorun.inf, and index.html. Remember to preserve the permissions as you copy everything over to the hard drive.

The left side of the panel in Figure 1 shows the CD's directory structure, while the right side shows the hard drive's partition.

screen shot of two directories
Figure 1. Copying files from the CD to the hard drive

Step 3: Copy the boot image

Copy the contents of the compressed kernel image from the CD. Mount the file /KNOPPIX/boot.img on a loop device and copy the contents from the device to /hardrive_boot/. I used these commands:

bash-2.05# /sbin/losetup /dev/loop0 /mnt/linux1/KNOPPIX/boot.img
bash-2.05# mount /dev/loop0 /mnt/floppy/
bash-2.05# cp /mnt/floppy/* /mnt/linux1/hardrive_boot

Step 4: Make the partition bootable

Here's an extract of my own LILO configuration. Your instructions will differ if you use something other than LILO.

image = /mnt/linux1/hardrive_boot/vmlinuz
	label  = knoppix
	initrd = /mnt/linux1/hardrive_boot/miniroot.gz
	root   = /dev/hdc2
	append = "lang=us"

Step 5: Update the bootloader (LILO)

Update the bootloader. In my case, this was:

bash-2.05# /sbin/lilo
Added linux *
Added knoppix
Added win2k

Step 6: Test the installation

Everything is now set and ready to go. Remove the CD and reboot your PC, choosing Knoppix from the bootloader's menu. The system will now behave as it would if booted from the CD.

Part 2. Preparing the Development Environment

Now that you have transferred the Knoppix distribution to the hard drive, it's time to create the development environment. This environment will consist of:

Step 1: Boot the Knoppix partition

You'll copy working copies of the file system to the development hard drive. Don't confuse this with the 710MB partition you created in earlier steps. This will require at least 3GB of space.

Step 2: Create directories

Figure 2 shows a mix of symbolic and hard links to the real directories and files located on the newly created partition.

screen shot of masterISO directory
Figure 2. The masterISO directory

Step 3: Copy the Knoppix file system

As root, copy the contents of the CD's KNOPPIX expanded directory to the hard drive. It's important to preserve all file attributes to be able to copy the devices. The copying will take a while; now is a good time to order pizza.

bash-2.05# cp -pR /KNOPPIX/* /mnt/hdc1/KNOPPIX_original
bash-2.05# cp -pR /mnt/hdc1/KNOPPIX_original/* /mnt/hdc1/KNOPPIX_remastered

Step 4: The scripts

To keep things straight in my head, I created three scripts. activates the swap drive. You may not need this, but I did.

/sbin/mkswap ./swapfile
/sbin/swapon ./swapfile

You can verify that this works by checking the amount of memory you have:

$ free -otm creates a compressed file system using mkisofs and a utility from the Knoppix distribution called create_compressed_fs. Copy create_compressed_fs to the current working directory on the development partition. This script contains the following commands, all on one line (though they've been reformatted slightly for publication):

mkisofs -R -U -V "PostgreSQL Live CD"
	-P ""
	-hide-rr-moved -cache-inodes -no-bak
	-pad ./KNOPPIX_remastered | nice -5 ./create_compressed_fs - 65536 >
	./masterISO/KNOPPIX/KNOPPIX creates the ISO image that will be burned onto a CD-R. Again, this script contains the following commands, all on one line:

mkisofs -pad -f -l -r -J -v -V "KNOPPIX" -b KNOPPIX/boot.img
	-c KNOPPIX/ -hide-rr-moved -o ./knoppix.iso ./masterISO/

Step 5: Create a swap file

If you don't have 1GB of RAM, you'll need a swap file:

bash-2.05# dd if=/dev/zero of=swapfile bs=1024 count=1000000

We've covered a lot of ground so far. You might wonder if it's worth the effort. The short answer is yes. If you want to do serious work and create a great self-booting CD, then you want to let your imagination run wild and try all sorts of ideas. The last thing you want to worry about is the menial command-line stuff or losing valuable time from a disaster compilation.

Figure 3 shows the completed development directory structure.

screen shot of completed directory
Figure 3. The completed directory structure

Part 3. Making a New Bootable CD

After much work, you now have a working image of the Knoppix distribution on the hard drive, the file system has been copied, and you have the scripts and the requisite RAM. Creating a successful, bootable CD is the process of removing and adding packages, followed by fine-tuning services and the user's account configuration files. Let's make it happen!

Step 1: Upgrading and installing packages

The very first thing to do is to make sure that your distribution has the most recent libraries and security patches. You can do this with the network applications available from the live-CD distribution. My own preference is to use my original, native distribution. GNU/Linux, as Debian calls itself, is remarkable in its ease of applying updates and patches. Knoppix is just as easy, by virtue of its lineage. You just need to use the Debian package management utilities to update the OS.

Assuming you are connected to the Internet, on your normal installation version of Linux, open a console as root and navigate to the KNOPPIX_remastered directory. Run chroot to get a new root directory:

bash-2.05# /usr/sbin/chroot ./

You may see a race condition consisting of /dev/null permission denied messages. If that happens, remount the drive with the nodev option set. Here's a sample configuration that I put in my own fstab file:

/dev/hdc1 /mnt/linux ext2 (rw,nosuid,nodev) 0 0

You will also need to mount the /proc file system within the console to allow Internet access and the use of such utilities as screen:

bash-2.05# mount -t proc /proc proc

At this point, I always invoke the screen application, since I always move from activity to another and end up running several jobs at the same time (such as reading documentation while doing an upgrade). Before going onto the Internet, assuming that you put your primary OS online before chrooting, make sure the chrooted resolv.conf file has the correct DNS entries for successful name resolution.

Updating the distribution will resynchronize the package index files from their sources. Use the apt-get update command. Upgrading will install the newest versions of all packages currently installed. You are now ready to install a package and all of its dependencies (though you may need to go to the Debian site to figure out the package name). Use the apt-get install <package name> command.

Step 2: Removing what you don't want

The process of removing packages correctly is critical. Removing too little means you can't install what you want, due to space restrictions on the CD. Removing too much runs the risk of removing those packages that make the live-CD functional. The Knoppix site has a lot of information on the subject of remastering on the Knoppix site. The technique presented here is to remove packages via a kick list.

The kick list is an ordered list of my personal list of unwanted packages. It is by no means the final word, so be prepared for a bit of experimentation as you figure out what you do and don't want. Copy the list and place it inside the chrooted root directory. The order of packages listed has been carefully researched. Editing the text file is straightforward; packages near the top do not have any packages dependent upon them. However, they themselves may be depend on packages listed further down. When you're satisfied with the list of packages to remove, use the command:

bash-2.05# apt-get remove `cat ./mykicklist.txt`

An alternate command uses the purge switch to remove configuration files specific to that package:

bash-2.05# apt-get purge `cat ./mykicklist.txt`

It is recommended to begin by removing only a small subset of packages; start with a small kick list. Don't worry if you make a mistake — you can use the same list to replace those removed packages:

bash-2.05# apt-get install `cat ./mykicklist`

If you would like to remove packages based on their size, then try this to see where you should start:

bash-2.05# dpkg-query -W --showformat='${Installed-Size} ${Package}\n' |
	sort -nr | less

Running apt-get clean will free up disk space after you've finished removing packages. You can run the scripts to make your compressed file system once you're satisfied with your changes. The remastering FAQ has more tips on removing and cleaning your installation. Remember to unmount /proc when you've completed editing your packages.

Step 3: Altering the desktop configuration

To tell you the truth, I love the Knoppix desktop and user interface setups, so I didn't change mine very much. But there will be times when you will want to change those defaulted user account settings. You can change user configurations in one of two ways:

Step 4: Running the scripts

You've fine-tuned the packages and configuration scripts. Now it's time to see your creation work. If you haven't already done so, now is the time to invoke (if you need the swap) and to run the free command to make sure you have 1GB of RAM. You will now cycle through the following steps until you're satisfied with your creation:

Permanently Installing the Live CD Operating System onto the Hard Drive

Do you like what you've created? Would you like to put this on your machine permanently as a real installation? Guess what? You can! There is a utility on the Knoppix live-CD that will create and format a file system and a swap partition, and will mirror the CD's file system to the hard drive. What is especially cool about this process is that it will install a true home directory with the standard session logins that you'd find in any standard installation of Linux.

Running the knoppix-hdinstall command will invoke a script that asks several questions, including where you want to install the distribution, the swap partition, and the type of the filesystem (ext2, ext3, reiser, or xfs). It will ask for user accounts that you may want to install, along with a password. The script finally copies the entire compressed file system from the CD onto the hard drive. Take note: there are no questions about configuring graphics or selecting applications to installed. After all, that's the whole point to this CD!


This article has just scratched the surface of what the Knoppix live-CD can do. Unfortunately the only published books on this distribution are in German. Although I've referenced Linux as the primary development platform, it is quite reasonable to extend this development environment onto other UNIX and Unix-like environments, such as Solaris and FreeBSD.


Knoppix home site

man Pages

Robert Bernier is the PostgreSQL business intelligence analyst for SRA America, a subsidiary of Software Research America (SRA).

Return to the Linux DevCenter.

Copyright © 2009 O'Reilly Media, Inc.