[University of Manchester]   [ISBE]



 +First run
 +bug fixes
 +TINA libraries
 +iso download
 +TINA memos
Remastering info

Remastering Instructions

This section describes the process of remastering the KNOPPIX cd to produce TINA Knoppix 3.0.0. It draws on two main sources; my previous remastering guide (which is outdated but still contains some useful information) and the official knoppix.net remastering guide. The remastering process described in this guide uses the qemu emulator to test the remastered .iso file, and so does not require any re-partitioning of your hard disk or any messing around with your boot loader, making it a lot easier and safer. However, you will need around 7GB of free disk space on an existing linux installation. Make sure that you back up any important data on your PC before you start.

Before you start, you will need to obtain a copy of the Knoppix .iso file from the Knoppix website and burn it to a CD using a CD burning program such a K3B. When burning an .iso file, make sure that you select the "burn image" mode and do not simply put the .ISO on the disk as a file.

You should also check that the CD boots, as this provides an opportunity to check that you can boot from a CD. If your PC boots into an installed operating system even with the Knoppix CD in an optical drive, you may need to change the boot order in bios. Reboot the PC and enter bios setup (this varies depending on your motherboard, but often you must press DEL during booting; see your motherboard manual or google for instructions). Check that your optical drives are listed before your hard drives in the boot order.

The versions used for producing TINA Knoppix 3.1.0 were:
  • Guest OS: Knoppix 6.4.3 (KNOPPIX_V6.4.3CD-2010-12-20-EN.iso)
  • Host OS: openSuse 11.3
  • qemu version 0.12.4
  • Tina 6.0 rcbuild 008

KNOPPIX manages to include about 2GB of linux software on a 700MB CD by using a compressed file system. Remastering involves extracting the contents of this compressed file system (which is contained in the large KNOPPIX file on the CD) and altering its contents. The compressed file system can then be recombined with the rest of the contents of the CD to produce the remastered .iso file. Therefore, copies of both the contents of the CD and the extracted file system are required.

Part 1: Set up the remastering environment

1) In the host OS, create a new directory called knoppix in your home area (allows you to avoid doing some operations as root, and thus makes the process safer), and within this create 4 new subdirectories:

knoppix_stuff: used to hold any random stuff you create.
knoppix_cd: used to hold a copy of the original cd (compressed knoppix file system).
knoppix_original: used to hold a backup of the expanded knoppix file system, in case you want to revert to the original).
knoppix_remastered: used to hold a copy of the expanded knoppix file system, which you will modify

2) Obtain knoppix ISO and put it in knoppix_stuff. Burn it to a cd and check that it boots.

3) Install qemu in the host OS. Then check that you can launch the knoppix ISO; cd to the directory containing the iso and use
qemu -m 2G -cpu coreduo -smp 2 -vga std -cdrom KNOPPIX_V6.4.3CD-2010-12-20-EN.iso
Command breakdown:
qemu Run the qemu emulator.
-m 2G Allow the virtual machine to use 2Gb of memory (check that you have this spare using free -otm).
-cpu coreduo Emulate a Core 2 processor.
-smp 2 Simulate a 2 processor SMP machine.
-vga std Simulate a standard vga graphics card.
-cdrom Run an operating system from a cdrom image.
KNOPPIX_V6.4.3CD-2010-12-20-EN.iso The cdrom image to run.

4) Put the cd in the drive and mount it from within the host OS. Copy the contents of the cd to the knoppix_cd directory. Remember to preserve permissions i.e. use cp -rP

5) Boot the Knoppix CD and, from within Knoppix, find and mount the disk partition containing your host linux home area. Then copy the contents of the /KNOPPIX directory to both knoppix_original and knoppix_remastered (created in step 1). The first will act as a backup in case we need to revert: the second will be the working area, where we will do the actual remastering. For example, if you linux partition is /dev/hdb3 and your remastering environment is in /home/user/knoppix, use
mount /dev/hdb3 /mnt/hdb3
cd /mnt/hdb3
mkdir KNOPPIX_original
mkdir KNOPPIX_remastered
cp -pR /KNOPPIX/* /mnt/hde2/home/user/knoppix/knoppix_remastered/
cp -pR /mnt/hdb3/home/user/knoppix/knoppix_remastered/* /mnt/hdb3/home/user/knoppix/knoppix_original/

6) Reboot into the host OS and write two scripts; create_KNOPPIX.sh and make_ISO.sh. The first of these takes the contents of the knoppix_remastered directory and uses it to create the compressed knoppix file system i.e. the large KNOPPIX file on the cd. The second takes a copy of the contents of the cd (including the new KNOPPIX file) and uses it to create the iso file. They could go anywhere with suitable alterations to the paths, but these were designed to go into the knoppix directory

mkisofs -R -U -V "TINA KNOPPIX Live CD 3.1" -P "paul.bromiley@manchester.ac.uk" -hide-rr-moved -cache-inodes -pad ./knoppix_remaster/ | nice -5 ./knoppix_remaster/usr/bin/create_compressed_fs -b -f ./isotemp -B 65536 - ./knoppix_cd/KNOPPIX/KNOX

Command breakdown:
mkisofs Create an iso filesystem.
-R Generate Rock Ridge extensions.
-U Be more flexible about allowed filenames.
-V "TINA KNOPPIX Live CD 3.0" Version name.
-P "paul.bromiley@manchester.ac.uk" Publisher name.
-hide-rr-moved Hide the Rock Ridge RR_MOVED directory.
-cache-inodes Do not copy hard linked files multiple times (saves space).
-pad Pad the end of the filesystem to avoid read-ahead bugs.
./knoppix_remaster/ Location of the remastered root realtive to the location of the script.
| Pipe the output of the previous command to the next command.
nice -5 Nice the process.
./knoppix_remaster/usr/bin/create_compressed_fs Use the script included with KNOPPIX to compress the filesystem.
-b Use the best compression possible.
-f ./isotemp Use isotemp as a temporary file during the creation of KNOPPIX.
-B 65536 Block size 65536
- Take piped input and...
./knoppix_cd/KNOPPIX/KNOPPIX ...compress it to the new KNOPPIX file.

mkisofs -pad -l -r -J -v -V "TINAKNOPPIX" -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 ./knoppix_cd/

Command breakdown:
mkisofs Create an iso filesystem.
-pad Pad the end of the filesystem to avoid read-ahead bugs.
-l Allow long filenames.
-r Set UID and GID to generic values.
-J Generate Joliet directory records (for use in windows).
-v Verbose mode.
-V "TINAKNOPPIX" Name of the CD.
-no-emul-boot Boot the cd without disk emulation.
-boot-load-size 4 No. of sectors in the boot table.
-boot-info-table Patch the boot image with a table describing the cd layout.
-b boot/isolinux/isolinux.bin Relative path to the isolinux.bin file in the knoppix_cd directory (relative to the path given as the last argument of this command).
-c boot/isolinux/boot.cat Relative path to the boot.cat file in the knoppix_cd directory (relative to the path given as the last argument of this command).
-hide-rr-moved Hide the Rock Ridge RR_M)VED directory.
-o ./knoppix.iso Location that the iso file will be written to.
./knoppix_cd/ Relative path from the script to the location of the knoppix_cd directory.

7) You are now ready to remaster and test. As a simple test, change the desktop wallpaper (e.g. with gimp), then run the create_KNOPPIX.sh script followed by the make_ISO.sh script. This will create a new knoppix.iso file in /knoppix/knoppix_stuff. Run this with qemu to check that the process has worked.

Part 2: Making some space

At this point the development environment is in place and you can begin to remaster Knoppix. If you want to install new software you will first have to make some space (remember that the final iso has to fit on a cd so must be smaller than 700MB). This is where the knoppix_remastered directory comes in: boot into your host linux OS, open a terminal, cd to the knoppix_remastered directory and (as root) type
chroot ./

This changes the root directory of the terminal to knoppix_remastered, allowing you to issue commands that alter the knoppix filesystem contained in that directory. WARNING: DO NOT CONFUSE TERMINALS TO YOUR HOST FILESYSTEM AND TERMINALS TO THE CHROOTED FILESYSTEM. IF YOU RUN SOME OF THESE COMMANDS ON YOUR HOST FILESYSTEM YOU COULD DO SERIOUS DAMAGE. YOU HAVE BEEN WARNED. To exit chroot, use Ctrl-D or type exit. The first thing to do is type
dpkg-query -W --showformat='${Installed-Size} ${Package}\n' | sort -n

to get a list of packages sorted by size (direct the output to a text file for ease of use). You can now scan the list of packages to identify software to be removed. Copy the names of packages you want to remove to a second file; your kicklist. Copy the kicklist to the knoppix_remastered directory and then, from within your chrooted terminal, type
apt-get remove --purge `cat my_kicklist.txt`

This will remove the listed packages. You may be removing packages upon which others depend; in this case apt will give you a list of packages with broken dependencies and also remove them; you can copy the list of packages to your kicklist to make the process cleaner in future. After removing software there may also be packages (particularly libraries) that are no longer in use (since they were depndecies of, and only of, some of the packages in your kicklist) these can be identified using

and removed using a second kicklist. Finally,
apt-get clean

will clean up after software installation. The kicklist used to prepare the TINA Knoppix 3.1.0 CD is provided here.

Part 3: Installing software

Knoppix is based on Debian, and so it is possible to download packages from the Debian website and install them manually from within the chrooted environment. However, it is generally easier to connect to the internet from within the chrooted environment and use the knoppix package manager. To set up internet access (assuming that the host system is connected), before entering the chrooted environment, copy the /etc/resolv.conf file from your host system to the knoppix_remastered/etc directory. This file contains your list of nameservers; remember to back out this change before you produce your final .iso file for distribution (you can use the copy in knoppix_original). Then, in the knoppix_remastered directory, type
mount --bind /dev /mnt/hda1/knx/source/KNOPPIX/dev mount --bind /proc /mnt/hda1/knx/source/KNOPPIX/proc mount --bind /sys /mnt/hda1/knx/source/KNOPPIX/sys

to mount the /dev, /proc and /sys directories from yout host filesystem within the knoppix environment, allowing it to access your internet connection. Then enter the chrooted environment; you should now have internet access from within that environment. Remember to unmount the /dev, /proc and /sys directories after you leave the chrooted environment. You should also modify the knoppix_remastered/etc/apt/sources.list with local sources (e.g. replace any occurences of .de with .uk; see the Debian website for a list of software repositories). Remember to back this change out before you distribute your remastered CD. Once you have internet access from within the chrooted environment and have updated the list of sources, type
apt-get update

to update the package list. Then, to list packages to install, type
apt-cache search .* | sort | less

and to install a package, type
apt-get install 'name-of-package-to-install'

Part 4: General tinkering

1) Integrate applications into the desktop:

One of the main reasons to remaster Knoppix is to add a piece of software that you want to showcase; it can therefore be useful to add a decktop icon for the program. Examples of .desktop files can be found in knoppix_remastered/usr/share/applications. Copy one of these to knoppix_remastered/home/knoppix/Desktop and it will appear on the desktop when you boot into the remastered version of knoppix (either from CD or using qemu). Edit it to point to your own software; see the TINA Knoppix CD for examples.

2) Change the desktop wallpaper:

This is in knoppix_cd/KNOPPIX and is called background.png. Modify it e.g with gimp.

3) Webpages:

The index.html file is in knoppix_cd, and links to several files in knoppix_cd/KNOPPIX; these can all be altered or replaced. You can also add a desktop icon for iceweasel (see point 1) and change the default homepage location in /home/knoppix/.mozilla/firefox/knoppix/prefs.jsto user_pref("browser.startup.homepage", "file:///mnt-system/index.html"); so that the Knoppix index.html file is opened; this provides an easy way to let users access documentation for your CD.

Part 5: Final Steps

Once you have altered the compressed file system in knoppix_remastered, run the create_KNOPPIX.sh script to create the compressed file system. followed by the make_ISO.sh script to create an iso file. Test this with qemu first and, if all is well, burn it to a CD.