Knoppix Remastered

Ever wanted to add/remove some things in Knoppix? here you find a german article that describes how it works. Because this article is in german and some things are not explained best, i tried to create a step by step receipe how to remaster a knoppix CD:

First you need some harddrive space. You'll need around 5GB. Create a build directory and go there. Copy a knoppix iso image somewhere near (or in the build dir).

We setup some directorys:

mkdir knoppix_cd
mkdir knoppix_fs
mkdir mountpoint

Mount the knoppix image (you could also mount a knoppix CD in a cdrom drive):

mount -o loop,ro knoppix.iso mountpoint

Copy the knoppix CD:

cp -a mountpoint knoppix_cd
umount mountpoint

Make it writeable:

chmod -R u+w knoppix_cd

Now we need to uncompress the image. The knoppix CD consists of a booting environment and this Image of the Knoppix environment. Therefore we need the cloop tools to uncompress the Knoppix environment. Download them from <- This link seems to be broken, but cloop tools are included in Suse 10.0. And compile the tools (we do not need the kernel module)

tar -xzf cloop_2.01-5.tar.gz
cd cloop-2.01
edit the Makefile and comment the line (if you have problems compiling the tools below):
# include $(KERNEL_DIR)/conf.vars
make create_compressed_fs
make extract_compressed_fs
mv create_compressed_fs ..
mv extract_compressed_fs ..

Uncompress the image:

./extract_compressed_fs knoppix_cd/mountpoint/KNOPPIX/KNOPPIX > cimage.iso

Copy image contents (the rsync seems to be necessary to avoid duplication of hardlinks):

mount -o loop,ro cimage.iso mountpoint
rsync -Hav mountpoint knoppix_fs

Now we can cleanup to save some disk space:

umount mountpoint
rm cimage.iso

Change something in the knoppix filesystem:

chroot knoppix_fs/mountpoint
mount -t tmpfs none /tmp
mount -t proc none /proc

now you can use all debian packaging tools to add/remove packages, and whatever u want. Keep in mind that the knoppix image is at the limit of a 800MB CD and you have to remove things if you want to add new ones. Remove temporary files and .bash_history things and that. If finished, exit the chroot:

umount /proc ; umount /tmp

Press CTRL-D to exit chroot. Next we create a compressed image:

mkisofs -pad -l -R -U knoppix_fs/mountpoint | ./create_compressed_fs -b - 65536 >

(the -b switch uses better compression but is very much slower. Ich you can, remove some more data and don't use -b :-))
This step needs large amount of RAM! You can split the pipe in two parts, but then you need another 2GB harddisk space.

Now we copy the compressed image back to the copy of the knoppix CD:

cp knoppix_cd/mountpoint/KNOPPIX/KNOPPIX

Create a new Knoppix CD image:

mkisofs -l -r -J -b KNOPPIX/boot.img -c KNOPPIX/ knoppix_cd/mountpoint > knoppix_remastered.iso

With Knoppix 3.6 (or probably earlier?) the boot mechanism changed. So we need:

mkisofs -l -r -J -v -V "Tiki Knoppix CD" -no-emul-boot -boot-load-size 4 -boot-info-table -b boot/isolinux/isolinux.bin -c boot/isolinux/ knoppix_cd/mountpoint > knoppix_remastered.iso

Burn it:

cdrecord -v -pad knoppix_remastered.iso

TikiWiki on a Knoppix CD

What do i have to do to get TikiWiki running at startup of a Knoppix CD:

Remove some packages. I removed:
dpkg --purge xskat
dpkg --purge xboing
dpkg --purge ace-of-penguin enigma enigma-data gnuchess
dpkg --purge gtans katomic kbattleship kmahjongg koules ksokoban xgalaga

Install Tiki somewhere. Create the database, fill it, configure your tiki. Go to admin->system and precompile the templates for the languages you want to use. Then

cp -a tiki knoppix_fs/mountpoint/var/www

Copy the mysql database (example: /var/lib/mysql/tiki) to your knoppix filesystem

cp -a /var/lib/mysql/tiki knoppix_fs/mountpoint/var/lib/mysql/tikilive

Make a symlink in yout knoppix fs

cd knoppix_fs/mountpoint/var/lib/mysql
ln -s /tmp/tiki tiki

Make a tiki startscript in knoppix_fs/mountpoint/etc/init.d/tiki

case "${1}" in
echo -n "Starting TikiWiki LiveCD Environment: "
cp -pr /KNOPPIX/var/lib/mysql/tikilive /tmp
mv /tmp/tikilive /tmp/tiki
exit 0
("restart" | "force-reload")
"${0}" stop
"${0}" start
echo "Usage: /etc/init.d/tiki {start|stop|restart}" >&2
exit 3

Automatic startup:

cd knoppix_fs/mountpoint/etc/rc5.d
ln -s ../init.d/apache S90apache
ln -s ../init.d/tiki S91tiki
ln -s ../init.d/mysql S92mysql