Knoppix remastering mini-howto ------------------------------ Last Modified: 3rd December 2004 Author: Daniel Stirnimann This mini howto shows how you can easily make your own customized knoppix build. Apart from that, there are a few techniques described which make doing changes conveniently. The howto is intended for people who work occasionaly on their builds. Content 1. Before you start 2. Unpack the knoppix source 3. Work on the knoppix build 4. Make the knoppix iso In this mini howto I use the file structure from my computer. For some commands you will have to replace the paths with the ones on your filesystem. Here is an overview of my directory structure: /--home/ |--daniel/ |--work/ |--knoppix/ # working directory |--compressed/ # mounted original knoppix iso |--source/ # working source directory |--release/ # final build directory 1. Before you start My computer has 512MB RAM and a swap partition of another 512MB. This is enough to build your own knoppix build. However, I don't know what effect less memory or swap space will have. You can create a swap file in case you think swap space could be a problem for you. Here are some tips on how to do that. - create a swap file of 500 MByte dd if=/dev/zero of=/swapfile bs=1024 count=500k mkswap /swapfile - activate the swap file swapon /swapfile - show active swap partitions/files cat /proc/swaps - show swap usage cat /proc/meminfo or top - deactivate swap partition swapoff /swapfile - delete the swapfile rm /swapfile You have to install the cloop kernel module as this is needed to mount the compressed KNOPPIX file. Get the cloop source from here: http://www.knopper.net/download/knoppix/ My cloop installation notes: make KERNEL_DIR=/usr/src/linux (source to 2.4.19) mkdir /lib/modules/2.4.19/kernel/misc (creates directory misc) mknod /dev/cloop b 240 0 cp cloop.o /lib/modules/2.4.19/kernel/misc/ Vincent Guffens suggests to make the following change to the cloop Makefile (version 1.x) on RedHat: KERNEL_DIR=/usr/src/linux # Uncomment the line if this is a redhat distro #REDHAT=-DREDHAT_KERNEL CFLAGS:=-Wall -Wstrict-prototypes -Wno-trigraphs -O2 -s -I. -fno-strict-aliasing -fno-common -fomit-frame-pointer -mpreferred-stack-boundary=2 -march=i386 $(REDHAT) It's a good idea to download the current knoppix ISO release. A list of mirrors is available at the knoppix website www.knoppix.org. 2. Unpack the KNOPPIX source - Mount the knoppix iso. You'll need the kernel loop module (CONFIG_BLK_DEV_LOOP) for that to work. mount -t iso9660 /path/to/knoppix.iso /mnt -o loop - Copy the KNOPPIX file to your local hd Note: I always had problems when I tried to mount the compressed KNOPPIX image directly from the mounted ISO image. The mounting of the KNOPPIX image was less a problem but copying the source from the KNOPPIX image always failed and left a copy process I couldn't even kill! You could copy the knoppix source from knoppix itself (after you have booted from a knoppix boot cd) but that always seemed to much work to me really. So, the solution I found reasonable is copying the compressed KNOPPIX image from the mounted ISO image to a directory and then mount the compressed KNOPPIX image with the cloop module. If I copy the compressed KNOPPIX image locally I have never had any source copying problems. So, this is what we are going to do next. cd /home/daniel/work/knoppix mkdir release/KNOPPIX cp /mnt/KNOPPIX/* release/KNOPPIX/ The above command copies also some other files such as boot.img and boot.cat. These files are needed later when we create our own knoppix boot cd. Actually, boot.cat could be removed as it is automatically created by mkisofs. Note, we didn't copy the top files on the knoppix image such as autorun.inf etc. If you want these files too you can copy them to release/. eg: cp -R /mnt/[DMTa-z]* release/ - Mount the compressed KNOPPIX file. insmod cloop file=release/KNOPPIX/KNOPPIX mount -o ro /dev/cloop compressed/ - Copy the knoppix source to your working directory mkdir source cp -Rupv compressed/* source/ - Umount the compressed KNOPPIX image umount /dev/cloop - Umount the mounted knoppix iso umount /mnt 3. Work on the knoppix build I use three ways of customizing my own knoppix build. First (a) is, from shell only, second (b) is you start X in the chrooted environment and third (c) and most comfortable is you work in your X environment and start a second X server which you then access from the chrooted environment to test X applications. I suggest you read through all three variations as I don't repeat some actions for each one. Initial steps are in all three variations needed so I start with them. - change to the source environment chroot /home/daniel/work/knoppix/source - mount proc file system mount -t proc /proc proc Don't forget to unmount the proc filesystem in the end. (a) Work from the shell only To customize the users home settings I suggest you do: - create a backup of the skeleton directory cd /etc tar -czf skel.tar.gz skel - copy the skeleton files to the home directory cd /home cp -R /etc/skel knoppix chown -R knoppix.knoppix knoppix/ - login as the knoppix user and make your changes su knoppix cd ~ (to go to the knoppix user home directory) In the end don't forget to cleanup - move changed files back to the skeleton directory. (exit from knoppix user to get root again) exit cd /home mv -R knoppix /etc/skel chown -R root.root /etc/skel (b) Start X in the chrooted environment You can run a second X server, so you don't have to exit your current session. This might not work for you, for example if you need the nvidia driver to get X working. In that case you might skip (b) and try (c). - go to terminal tty2 or any other which is free. you probably only use tty1 at the moment. You can switch between the screens with Alt+F1, Alt+F2. Alt+F1 = tty1 Alt+F2 = tty2 Alt+F7 = xserver :0 Alt+F8 = xserver :1 (the one we are going to start ;-) - setting the X server configuration up Copy the /etc/X11/XF86Config-4 file from your computer to the knoppix source to /etc/X11/. Don't forget to delete this file after you have made the changes to the knoppix source. - log in as the knoppix user (see steps from a). - start X export WINDOWMANAGER=/usr/X11R6/twm export WINDOWMANAGER=/path/to/your/windowmanager startx -- :1 (c) Display X application in your "normal" X environment Sometimes, I just need to make some minor changes to the knoppix source. When I then need to test an X application it is often convenient to have it opened in your "normal" X environment. - start a second X server in your "normal" X environment start xterm or any other x terminal and type: Xnest -ac :1 - go back into the chrooted knoppix environment and start kde3 export DISPLAY=localhost:1 startkde You can now work in both environments and do some tasks in one window and some in the other. (optionally) - To use a different desktop than kde try this instead of typing startkde: export WINDOWMANAGER=/usr/bin/gnome-session or export WINDOWMANAGER=/usr/X11R6/bin/twm startx 4. Make the knoppix iso - exit from the knoppix source to get to your "normal" environment - copy the create_compressed_fs tool cp source/usr/bin/create_compressed_fs /usr/local/bin/ - create a compressed knoppix file (~30min) mkisofs -R -l -V "KNOPPIX iso9660 filesystem" -hide-rr-moved \ -v source/ | create_compressed_fs - 65536 > release/KNOPPIX/KNOPPIX - create your knoppix iso file mkisofs -l -r -J -V "KNOPPIX-MyBuild" -hide-rr-moved -v \ -b KNOPPIX/boot.img -c KNOPPIX/boot.cat -o my-knoppix.iso release/ - burn the iso eg: cdrecord -v dev=0,0,0 speed=4 release/my-knoppix.iso or use your favourite cd writer software. References: 1) http://www.es.gnome.org/cgi-bin/cvsweb/gnome-live-cd/doc/ modificar_knoppix2.txt?annotate=1.1&cvsroot=GNOME 2) http://alamo.satlug.org/pipermail/satlug/2002-August/004254.html 3) http://gryphius.darktech.org/~gryphius/ Special Thanks: Thanks to Gryph (3) for showing me that you can do customized knoppix builds. Changelog: 17.11.2002, initial release 06.12.2002, 3.c) command for starting kde3 simplified 27.12.2002, 3.b) command for starting X simplified 3.c) command for starting X generalized 29.12.2002, 2) changed the process of copying the KNOPPIX source 05.01.2003, 2) by Gryph: cloop installation notes, copy command added! hint, loop module is needed. 3.b) by Gryph: hint that this wont work all the time. 17.02.2003, 1) dd command count had false size suffix. thanks to Gryph 16.09.2003, 2) Ahmad Twaijrt found a mistake in the command for 'copy the KNOPPIX file to the local hd' in which the destination was a directory which didn't exist. 4) Ahmad Twaijrt noted that the mkisofs command assumed some directories which I didn't tell should be created. 10.07.2004, fixed spelling and changed intro text. 03.12.2004, 1) cloop Makefile change for Redhat. Contributed by Vincent Guffens