Remaster Knoppix without Remastering

by Kyle Rankin

Knoppix is pretty easy to remaster and many people have created their own Knoppix variant to suit their needs. However there are a number of tweaks and changes you can make that don't require a complete remastering if you take advantage of the knoppix.sh script. I'll go over some of the advantages to this approach over a full remastering below.

I have watched quite a few people get introduced to Knoppix for the first time. After they use it for awhile they invariably want to tweak things. They usually either want to change some of the desktop settings or add their favorite program. Most of the time they decide to create their own version of Knoppix with a complete remastering.

Now there's nothing wrong with remastering, but it is rather time and resource intensive, and there are some margins for error, especially the first time you try it. If you have minor tweaks, I think it is better to take advantage of Knoppix's saveconfig script and knoppix.sh file it creates to change and tweak settings without a full remaster.

The saveconfig script



The saveconfig script within Knoppix is probably the best way to "remaster" Knoppix without remastering. You can type saveconfig from a terminal, or otherwise you can click Kmenu->KNOPPIX->Configure->Save Knoppix configuration. A simple GUI will pop up and allow you to choose what categories of settings to save from desktop and program settings, the entire Desktop directory, network settings, graphics settings, and other system settings. Choose the settings to save, and the device to save them to (from a list of detected devices Knoppix provides), and the script does the rest, creating a configs.tbz and knoppix.sh file on the device you chose.

Next time you boot, add the cheat code myconfig=scan and Knoppix will scan all available devices for the knoppix.sh script and then execute it. This script will extract configs.tbz and otherwise restore your settings.

If you are the kind of person who likes to hack around with things, you might think to yourself: "Hmmm I bet I could tweak that knoppix.sh script and do other things at boot." And you would be right, the knoppix.sh script is the key to remaster Knoppix without remastering.

What is the knoppix.sh script?



The knoppix.sh file is a simple shell script. When Knoppix boots, it scans the KNOPPIX directory on the CD for a knoppix.sh file (or if you use the myconfig=scan cheat code, it will also scan other devices on your system). If it finds this file, it will execute it. Windows users can think of this file as an autoexec.bat script. You can basically put any series of commands into this script and Knoppix will execute them upon startup. A typical knoppix.sh script looks like this:


#!/bin/sh
[ "`id -u`" = "0" ] || { echo "You need root privileges to modify the system!" >
&2 ; exit 1; }
[ -d "$1" ] && CONFIGS="$1/configs.tbz"
[ -f "$CONFIGS" ] || CONFIGS="/cdrom/KNOPPIX/configs.tbz"
[ -f "$CONFIGS" ] || CONFIGS="/mnt/floppy/configs.tbz"
if [ -f "$CONFIGS" ]; then
echo "^[[1mExtracting config archive $CONFIGS...^[[0m"
tar -jpPtf "$CONFIGS" | while read i; do rm -f "$i"; done
tar -jpPxf "$CONFIGS" ; chown -R knoppix.knoppix /home/knoppix
fi


The best way to get started with tweaking this file is to run the saveconfig script once to generate a knoppix.sh file to work from. There are some various checks this script runs, but its basic function is to extract the configs.tbz file. Based on what settings you saved, this file will overwrite settings in /etc or /home/knoppix. You can simply change the configs.tbz file if you want and add or remove files with the settings you want.

It's important to remember that certain parts of the filesystem under Knoppix, such as all of /usr, will be read-only even when the system completely boots, so this means that the interesting areas you will be able to change are in /etc/ and /home/knoppix/. Also, at the time knoppix.sh runs, /home/knoppix doesn't exist yet (that directory is copied from /etc/skel later), so while you might think that you can just add a cp filename /home/knoppix/ command to the script, it will fail when you run it. If you want to copy files to /home/knoppix, you will need to create a tarball from / that includes those files, that way the /home/knoppix directory will be created for you as that extracts.

Install Programs



While this setup is typically used for saving your settings, you can also work around having to install programs with this method. Knoppix has two different popular methods for installing software directly to the live CD, the included knx-live-inst.sh script (or click Kmenu->KNOPPIX->Utilities->Install Software while running from CD), or klik. Both of these programs install software directly into the /home/knoppix directory and modify file paths so that they can run from there. After you install programs with this method, you can save your home directory and those programs will still be there the next time you boot with myconfig=scan.

If your program isn't included in the list of software you can live-install, you can attempt to install it to the local path yourself. Of course this process will vary in difficulty depending on the complexity of the software you want to install.

Advantages over Remastering



There are other advantages to using these tweaks over a full remaster. For one, you can carry your custom knoppix.sh script and any other files it needs with you on a usb key drive, and can use any generic Knoppix CD you happen to find. Since the usb drive is more portable than a CD-ROM, you are probably more likely to have it in your pocket. In a pinch you could boot up with your custom setup on a friend's Knoppix CD.

You can also make changes much more quickly with this method. With a full remaster, each change you make requires that you create another compressed KNOPPIX filesystem (which is time-consuming) and another .iso. With this method you just have to re-run saveconfig or edit knoppix.sh. Also, if you have come up with a really cool knoppix.sh script, it's much easier to make available on a website for download compared to a complete custom Knoppix .iso.

Another advantage to this method is that you can maintain multiple knoppix.sh scripts on a single usb drive. Name the individual configs something other than knoppix.sh, and when you want to use one of them, just create a copy called knoppix.sh. This copy will be the one executed the next time you boot Knoppix and use myconfig=scan. I use this on my usb key drive so I can switch between a general customized desktop knoppix.sh file I have, and one that turns Knoppix into a full-fledged kiosk (based on a Hack I included in Knoppix Hacks). I can toggle between these settings without having to carry around multiple Knoppix CDs.

You can even burn a knoppix.sh script to a Knoppix CD provided all of the other files remain the same. Put the knoppix.sh file and any tarballs it needs into the KNOPPIX directory on the CD and it will execute the script when it boots. I used this method when I created the CD included with Knoppix Hacks. I didn't want to change around the actual KNOPPIX compressed filesystem, but I wanted to create a custom background and add a few links to the desktop. I created a tarball of the desktop links, and changed the background.jpg on the CD. This way I wouldn't unknowingly risk introducing any bugs into the compressed filesystem--something that was rather important since I couldn't modify the CD after it was shipped with a book!

If you are a Knoppix user who is thinking of starting the remastering process, I recommend trying knoppix.sh tweaks first. You'll likely save yourself time and blank CDs in the process.