Remaster Knoppix without Remastering

Why go through complicated steps to remaster Knoppix, when there are a number of methods to get the most of the functionality without the fuss?
Example: Webcam

Here's an example of a tweaked file that I made to turn Knoppix into an instant Webcam server. I first created a webcam directory on the CD-ROM and put a basic HTML file there that pointed to an image at /var/www/webcam.jpg. Then, I created a script and put it in the KNOPPIX/ directory on the CD. Here is the script:


echo Configuring Apache
cp /cdrom/webcam/index.html /var/www/index.html
/etc/init.d/apache start
echo Configuring Cron
echo '* * * * *  root gqcam -d /var/www/webcam.jpg > /dev/null' >>
/etc/init.d/cron start

As you can see, there isn't much to this script. I copy the HTML file to the default Apache document root, start Apache, and then add a job to the global crontab and start cron. The cron command will run gqcam every minute, which will capture an image and store it in /var/www/webcam.jpg. Now, I can just burn the CD and boot it on any machine with a Webcam and Knoppix will take care of the rest.

Persistent Disk Image

In addition to the saveconfig script, Knoppix provides an even more advanced script that creates a persistent disk. The main problem with a live CD is that all of your changes are erased whenever you reboot. Traditionally, the persistence script created a loopback filesystem on a USB key or hard drive of a specified size and then copied your entire home directory to it. On the next boot, if you selected it with a cheat code, Knoppix would then mount the filesystem and point your entire home directory to it. That meant any changes you made to your home directory were kept through all of your reboots.

The main limitation to that script (as with legacy Knoppix discs) was that you could write only to certain directories. Beginning with Knoppix 3.8, Knoppix added UnionFS (now replaced with AuFS). This tool essentially allows you to merge filesystems on top of each other, even if one is read-only and the other is read-write. If you wrote to the filesystem, UnionFS/AuFS transparently took care of putting the writes on the correct filesystem. With Knoppix, this now meant the ramdisk that was traditionally used for /home and /etc could now be merged on top of the entire filesystem. You now could essentially write anywhere you wanted, install programs using the standard Debian package management, and basically treat the system like any other installed Linux distribution, limited only by your ramdisk size.

With the addition of AuFS, Knoppix changed its persistence script. Now when you click K→Knoppix→Configuration→Create a persistent Knoppix disk image, Knoppix creates a complete copy of the entire ramdisk. This is a copy of all of the changes you have made to the system since you have booted. Within the script, you can choose the maximum size of the filesystem, where to store the image, and even whether to use encryption. The next time you boot, if the USB or local hard drive is present, Knoppix automatically detects it and prompts you with a few options:

  • Home: use only your persistent home directory.

  • System: replace the entire /ramdisk mountpoint with the persistent disk image.

  • Overwrite: off by default, but it will replace the /etc directory on your persistent image if you also enable the System option. You might want to do this if your system-wide graphics or network settings from a previous machine interfere with your current one.

  • Init: start any persistent init scripts.

If you don't select any of these options, Knoppix will boot normally. It's also possible that you might have multiple knoppix.img files on different drives (or multiple files on the same drive in different directories). This actually is a good way to create custom Knoppix settings that are stored in different directories on a USB key. Say I have a security-focused persistent image in the security directory on my USB key (which Knoppix detects as /dev/sda1), I could then boot Knoppix with the home=/dev/sda1/security/knoppix.img cheat code.

Tweak Boot Settings

The saveconfig and tweaks provide a lot of functionality, but their main downside is that they execute at the end of the boot process. Sometimes you want to change Knoppix settings sooner than that—whether it's the default screen you see at boot time or Knoppix's default cheat codes. These options and more are stored in the boot/isolinux/ directory on the disc and can be changed without much effort. Below I cover some of the more important files and what you can change with them.

Boot messages: the boot.msg, f2 and f3 files are text files that define what shows up at the boot prompt, when you press F2 and F3, respectively. If you want to add special help or even change the text completely, you can do so in these files.

isolinux.cfg: this is one of the most useful files in this directory, as it defines all the different kernels that can be loaded, along with their default boot options. For instance, here is the section of the file that defines the default Knoppix settings and cheat codes if you let the boot prompt time out or just press Enter:

LABEL knoppix
KERNEL linux
APPEND ramdisk_size=100000 init=/etc/init lang=us apm=power-off vga=791
inirt.gz nomce loglevel=0 quiet BOOT_IMAGE=knoppix

For instance, you can see here that the default language is English, but if you wanted to change it to Spanish, you would change lang=us to lang=es. If you scroll down farther in the file, you can not only see other Knoppix types you can boot, but also listings for memtest and dos.


Kyle Rankin is Chief Security Officer at Purism, a company focused on computers that respect your privacy, security, and freedom. He is the author of many books including Linux Hardening in Hostile Networks, DevOps Troubleshooting and The Official Ubuntu


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Persistent Disk Image

Adel Afsharipour's picture

Hi Dear Kyle
Thanks for the info. Currently I'm using Knoppix version 6 and as it has switched to LXDE, the instruction for the creating persistent disk image, as you said by selecting from menu ... is not available.
I have two questions:
1) How can I create the disk imgae from the terminal ?
2) After creating a disk can I resize it ?
Thanks a lot.
Best regards