Knoppix Linux From Zero to GNU/Linux in Five minutes Home | About | Search | Docs | Get Knoppix | Forum | Bugs | Contact | » Knopper.net Knoppix Wiki Home | RecentChanges | LikePages | BackLinks | Search Wiki : Knoppix Remastering Howto Translations: * German Version: KnoppixRemasteringHowtoDeutsch * Spanish Version: KnoppixRemasteringHowtoSpanish en español ------------------------------------------------------------------------ See also : * If you want to add a custom kernel, check out the KnoppixCustomKernelHowto * There also a guide at O'Reilly on the same topic : httpUsing and Customizing Knoppix ------------------------------------------------------------------------ This is a guide that will show you how to remaster KNOPPIX (Notes : commands should appear on one line, so please maximize the window. If you have any comments/suggestions please post below.) You may wish to start from an already customized Knoppix, so you don't have to do as much work (such as removing programs). If so, see KnoppixCustomizations. System Requirements: * at least 1 GB of FREE RAM+Swap total (e.g. 256M ram, and 750M swap AVAILABLE) (unless you use a different compression program - look in this page for compressloop) * 3 GB free on a *Linux filesystem (ext2/3, xfs, etc.)* formatted disk partition Instructions: * Boot from Knoppix CD * Configure your Internet connection (we'll need this later) * Open a root shell (Kmenu->Knoppix->Root Shell) - all commands below are run from this root shell * Find the partition you will use to work on. In this example it is called *hda1* . The partition should have a minimum of 3 GB free space * Mount the partition: *mount -rw /dev/hda1 /mnt/hda1* (do it like this or you'll get errors when you later chroot) * Create a root directory to work in: *mkdir /mnt/hda1/knx* (put all your files here and it will be easy to clean up) * If you don't have 1 GB RAM (cat /proc/meminfo (physical+swap)) then you will need a swapfile: *cd /mnt/hda1/knx ; dd if=/dev/zero of=swapfile bs=1M count=750 ; mkswap swapfile ; swapon swapfile* * Make 2 directories, one for your new Master CD, one for the source, on a disk partition: *mkdir /mnt/hda1/knx/master; mkdir /mnt/hda1/knx/source* * *mkdir /mnt/hda1/knx/source/KNOPPIX* * now, copy the KNOPPIX files to your source directory : *cp -Rp /KNOPPIX/* /mnt/hda1/knx/source/KNOPPIX* that will take a little while :) * *mkdir /mnt/hda1/knx/master/KNOPPIX* * *cp /cdrom/index.html /mnt/hda1/knx/master/ * * now, copy everything in /cdrom/KNOPPIX/ to /mnt/hda1/knx/master/KNOPPIX/ except the ~700 Mb KNOPPIX file. ( *cd /cdrom/KNOPPIX;find . -size -10000k -type f -exec cp -p --parents {} /mnt/hda1/knx/master/KNOPPIX/ \;* ) * *(For Knoppix 3.4)*, copy everything in /cdrom/ to /mnt/hda1/knx/master/ except the ~700 Mb KNOPPIX file. ( *cd /cdrom;find . -size -10000k -type f -exec cp -p --parents {} /mnt/hda1/knx/master/ \;* ) * Now you can "chroot" into the copied KNOPPIX : *chroot /mnt/hda1/knx/source/KNOPPIX* If you get a whole lot of */dev/null permission denied* errors, you should do the following. Check your mount status if you met the problem: *mount /dev/hdaX on /mnt/hdaX type ext3 (rw,nosuid,nodev)* (replace X with your partiton number ) where "nodev" means that you are not accessible on mounted filesystem and you can not access /dev/null. And some scripts get output redirect to /dev/null... To solve this you should mount the target partition before you do chroot like this: mount /dev/hda1 /mnt/hda1 And see whats changed: mount /dev/hda1 on /mnt/hda1 type ext3 (rw) If the /dev/null warnings persist then before the chroot do : mount --bind /dev /mnt/hda/knx/source/KNOPPIX/dev You have to umount /mnt/hda/knx/source/KNOPPIX/dev before building the CD image or your /dev directory on the CD will be messed up! then you can carry on and chroot. * You are now chrooted. "/" is actually "/mnt/hda1/knx/source/KNOPPIX" * To use the internet you need to mount proc *mount -t proc /proc proc* * now edit /etc/resolv.conf and add your nameserver or *cp /etc/dhcpc/resolv.conf to /mnt/hda1/knx/source/KNOPPIX/etc/dhcpc/resolv.conf* * Also change smb.conf to your MS group if you want smbd support (MSHOME is XP Home ed. usually, and WORKGROUP is 9x Windows. * check your chrooted internet connection : *ping google.com* * Update your package list with *apt-get update* * Now you can change stuff. o Before you can add stuff, you will probably need to remove some packages. To get a list of packages installed, type this: + *dpkg-query -l* o If you want that list sorted by size (this way you can get rid of the biggies), type this: + *dpkg-query -W --showformat='${Installed-Size} ${Package}\n' | sort -n* o To remove a package (and all packages dependant on it), type this: + *apt-get remove * o To check for orphaned packages, type this: + *deborphan* o Want to save more space by getting rid of those pesky orphans (how cruel!), type this (*Warning*, you won't be prompted yes/no to remove these packages. When you press Enter after this command, those packages *will be gone*): + *deborphan | xargs apt-get -y remove* o If you're uncertain about the previous command and want to see what will happen without making any changes, just add the *-s* option to the apt-get command like this (you can do this with all of the apt-get commands, and it's a good habit to use this option before mass operations like this one): + *deborphan | xargs apt-get -s -y remove* o Now the good stuff. If you wish to add a package, type this: + *apt-get install * o What, don't know what packages to install? Type this. When the list appears, you can peruse (over 13k lines!) or search for things using */*: + *apt-cache search .* | sort | less* o When you're done removing and adding packages, a good way to clean up is by typing this: + *COLUMNS=200 dpkg -l |grep ^rc |awk '{print $2} ' | xargs dpkg -P* o Also, because the Debian package system keeps a cache of downloaded packages, you may want to run the following to clear out those spare files: + *apt-get clean* o user settings are in /etc/skel * Unmount /proc - very important! *umount /proc* * Press *CTRL+D* to leave being chrooted. Notes : When you want to autorun some programs, one can create a script and put it in the directory /etc/rc5.d/ (This only loads items before X loads) interesting stuff in /etc/init.d/knoppix-autoconfig : * The X background file is /cdrom/KNOPPIX/background.gif *(in knoppix 3.4: background.jpg)* * As well as floppyconfig, there is cdromconfig which will run cdrom/KNOPPIX/knoppix.sh interesting stuff in /etc/init.d/xsession : * it ALSO sets background as /usr/local/lib/knoppix.gif Now, onto creating the ISO file : * we've finished customizing and ready to burn! * first do some cleanup : * remove .bash_history files, tmp files etc * * *rm -rf /mnt/hda1/knx/source/KNOPPIX/.rr_moved* * Now we'll make the big KNOPPIX file which is a cloop compressed ISO 9660 filesystem : *mkisofs -R -U -V "KNOPPIX.net filesystem" -P "KNOPPIX www.knoppix.net" -hide-rr-moved -cache-inodes -no-bak -pad /mnt/hda1/knx/source/KNOPPIX | nice -5 /usr/bin/create_compressed_fs - 65536 > /mnt/hda1/knx/master/KNOPPIX/KNOPPIX* the "www.knoppix.net" and "Knoppix.net filesystem" can be changed to what you want to call the file. You will get an error that it doesn't conform to ISO standards, you can ignore this. In Knoppix 3.4 the create_compressed_fs script has been updated so be sure to use it to obtain the best result. It has a new option *-b* (best), which enables the best compression by using different compression schemes and tries to optimize that way, but be careful, because that option is slow (10x slower). * if all went well, onto making the final CD-ROM Image : * *cd /mnt/hda1/knx/master* * *rm -f KNOPPIX/md5sums; find -type f -not -name md5sums -not -name boot.cat -exec md5sum {} \; >> KNOPPIX/md5sums* (this will update the md5 hashes of the files included in the ISO, used for integrity checking) * *mkisofs -pad -l -r -J -v -V "KNOPPIX" -b KNOPPIX/boot.img -c KNOPPIX/boot.cat -hide-rr-moved -o /mnt/hda1/knx/knoppix.iso /mnt/hda1/knx/master* (the ISO is stored in /mnt/hda1/knx/knoppix.iso) * For Knoppix 3.4 or other isolinux based distributions do: *mkisofs -pad -l -r -J -v -V "KNOPPIX" -no-emul-boot -boot-load-size 4 -boot-info-table -b boot/isolinux/isolinux.bin -c boot/isolinux/boot.cat -hide-rr-moved -o /mnt/hda1/knx/knoppix.iso /mnt/hda1/knx/master* (the ISO is stored in /mnt/hda1/knx/knoppix.iso) * all done! Tips If you are looking for big installed packages then the command dpkg-awk "Status: .* installed$" -- Package Installed-Size | \ awk '{print $2}' | egrep -v '^$' | xargs -n2 echo | \ perl -pe 's/(\S+)\s(\S+)/$2 $1/' | sort -rg will list the packages with size in descending order. At least ten times faster is the command dpkg-query -W --showformat='${Installed-Size} ${Package}\n' | sort -n and you don't need dpkg-awk or awk or perl. If you have trouble with the above sort command, try using KPackage, expanded all the trees and sorted by the size column to find big packages. Check out the program "deborphan", it will list orphaned packages that you can remove, these packages were used by packages that are now removed. I have had good results remastering working from the cd as root working from fluxbox. Just say "knoppix 2" at the boot prompt and it will boot you to a root prompt where you can then say "startx /usr/bin/fluxbox". I like to use the xterm unicode shell. While working chroot doing the remastering I like to use "apt-get remove --purge pkg-name" to remove packages because before it does anything it will stop and show detials on what it is fixing to remove and let you say "yes or no". If you don't use the above "apt-get" instructions and have a lot to cleanup and purge, here's the easy way to do it: "COLUMNS=200 dpkg -l |grep ^rc |awk '{print $2} ' >topurge". That will make a list of all removed packages to purge and then you just say "dpkg -P `cat topurge `" and your all done. "COLUMNS=200 dpkg -l |grep ^rc |awk '{print $2} ' | xargs dpkg -P" is a one-line version of this. Also use "deborphan >orphaned" then "dpkg -P `cat orphaned `". "deborphan | xargs dpkg -P " is a one line version for that. Thats it. This is an updated version of my previous howto. This is not meant for linux beginners, you will need to know your way around linux to get this to work. I'll update this as corrections/improvements/etc come through. Thanks to aay, charan, Tech2k, and #knoppix for some corrections and tips and ideas. Feel free to edit or add to this howto. * Don't forget to give toast some love here! lol... Note about swap: You don't really need 1G swap as there are two new tools to create compressed filesystems. Here are some candidates to make_compressed_fs: * Valentijn's rewrite httphttp://projects.openoffice.nl/downloads/compressloop/ * Quozl's port of compressloop for Knoppix 3.4 httphttp://quozl.linux.org.au/compressloop-1.9-64bit.c * Justin's patch httphttp://s.bouncybouncy.net/~justin/code/ (link broken) I also just wrote a distributed cloop compressor(or for smp) It's in that same directory. Tip, test cd-image without recording cd If you have a spare partition with at least 700MB free space formatted with ext2, ext3 or Vfat, you can use this for test by booting from a floppy disk. A floppy boot will look for a partiton with /KNOPPIX/ in the root, and the compressed image /KNOPPIX/KNOPPIX. Instead of using the sub-directory /mnt/hda1/knx/master/KNOPPIX/ as described above, it should be called /mnt/hda2/KNOPPIX/ . The root index.html will then be located at /mnt/hda2/index.html and the compressed image will be at /mnt/hda2/KNOPPIX/KNOPPIX . Now you can boot from floppy and use /mnt/hda2 as your image. For further information see HdBasedHowTo. Booting Knoppix images with GRUB * First copy /boot of the Knoppix cd to your boot partition (or even your dos partition). I named mine boot.knoppix * Copy the /KNOPPIX directory to your *root directory* of any hard disk. You may place it somewhere other than the boot partition. (ext2/3, reiserfs, vfat are supported) * put the following in your /boot/grub/menu.lst: title KNOPPIX root (hd0,0) kernel /boot.knoppix/vmlinuz 2 fromhd=/dev/hda4 lang=us initrd /boot.knoppix/miniroot.gz * notice the fromhd parameter: it's the location of the /KNOPPIX directory * reboot and have fun. If my howto is too confusing, or you'd like a second opinion, check out charan's very nice remastering howto : httphttp://gnubox.dyndns.org:8080/~sunil/knoppix.php . Another Howto is at httphttp://www.stirnimann.com/mystuff/doc/knoppix.txt There is a wizard, which knows all the unpacking, compressing and CD-recording steps mentioned here. It also shows a shell where you can update the uncompressed KNOPPIX system using debians standard software installation tools. It is called mmkcdrom and part of the plugscript package: httphttp://rcswww.urz.tu-dresden.de/~holzhey/plugscript Be sure to check out the httpKnoppix Customization Forum for ideas and help with remastering. ------------------------------------------------------------------------ This is the recommended directory layout for remastering KNOPPIX: . (invoke ../remaster from here) |-- master (invoke ../../umountbootimage from here) | |-- KNOPPIX | | |-- KNOPPIX (compressed image) | | |-- boot.img (boot floppy image) | | `-- (other files snipped) | `-- index.html `-- source `-- KNOPPIX (this directory can be chrooted into) |-- bin |-- boot |-- cdrom |-- dev |-- etc |-- floppy |-- home |-- initrd |-- lib |-- mnt |-- none |-- opt |-- proc |-- root |-- sbin |-- tmp -> /var/tmp |-- usr |-- var `-- vmlinuz -> boot/vmlinuz-2.4.22-xfs ------------------------------------------------------------------------ the following script "remaster" will do the remaster process for you. Use as root, or you will end up with wrong access rights in the image. The script has last been tried out on Debian sid on 2004-04-02. #!/bin/bash -x # This script builds a new KNOPPIX ISO image. # Copyright (C) 2004 by Marc Haber # License: GPL V2 ROOT="$PWD" SOURCE="$ROOT/source/KNOPPIX" MASTER="$ROOT/master" CLOOPTARGET="$ROOT/master/KNOPPIX/KNOPPIX" TARGET="$ROOT" EXCLUDELIST="$ROOT/source/excludelist" rm -rf $SOURCE/.rr_moved cd $SOURCE mkisofs -R -U -V "KNOPPIX.net filesystem" \ -P "KNOPPIX www.knoppix.net" \ -hide-rr-moved -cache-inodes -no-bak -pad \ -exclude-list $EXCLUDELIST \ . | nice -5 /usr/bin/create_compressed_fs - 65536 > $CLOOPTARGET cd $MASTER rm -f KNOPPIX/md5sums find -type f -not -name md5sums -not -name boot.cat -exec md5sum {} \; >> KNOPPIX/md5sums mkisofs -pad -l -r -J -v -V "KNOPPIX" -b KNOPPIX/boot.img \ -c KNOPPIX/boot.cat -hide-rr-moved -o $TARGET/knoppix.iso $MASTER ------------------------------------------------------------------------ The following script will loop-mount boot floppy image and initrd image for modification. The umount function will build a new initrd image and put it back on the boot floppy image. The script has last been tried out on Debian sid on 2004-01-13. #!/bin/bash -x # This script will loop-mount boot floppy and initrd image # Copyright (C) 2004 by Marc Haber # License: GPL V2 unset CDPATH || true # if not root, re-invoke self as root if ? <%22%60id%20-u%60%22%20-ne%200?action=edit>_"`id -u`" -ne 0_; then export LOCUSER="$USER" export LOCHOME="$HOME" if ? <%22%24%7BSHELLOPTS/xtrace/%7D%22%20%21%3D%20%22%24SHELLOPTS%22?action=edit>_"${SHELLOPTS/xtrace/}" != "$SHELLOPTS"_; then sudo bash -x $0 $@ exit $? else sudo $0 $@ exit $? fi else LOCUSER="${LOCUSER:-$USER}" LOCHOME="${LOCHOME:-$HOME}" fi set -e KNOPPIXDIR="KNOPPIX" BOOTIMGFILE="$KNOPPIXDIR/boot.img" BOOTIMGFS="vfat" BOOTIMGDIR="boot.img" INITRDGZ="$BOOTIMGDIR/miniroot.gz" INITRDFILE="$KNOPPIXDIR/miniroot" INITRDFS="ext2" INITRDDIR="miniroot" mountbootimage() { if ! modprobe loop; then echo >&2 "ERR: cannot load loop module" exit 1 fi if ! ? <-e%20%22%24BOOTIMGFILE%22?action=edit>_-e "$BOOTIMGFILE"_; then echo >&2 "ERR: no $BOOTIMGFILE found" exit 1 fi for nofile in $BOOTIMGDIR $INITRDGZ $INITRDFILE $INITRDDIR; do if ? <-e%20%22%24nofile%22?action=edit>_-e "$nofile"_; then echo >&2 "ERR: $nofile already exists" exit 1 fi done mkdir -p $BOOTIMGDIR mount -o loop,uid=$LOCUSER -t $BOOTIMGFS $BOOTIMGFILE $BOOTIMGDIR < $INITRDGZ gunzip > $INITRDFILE mkdir -p $INITRDDIR mount -o loop -t $INITRDFS $INITRDFILE $INITRDDIR } umountbootimage() { dd if=/dev/zero of=$INITRDDIR/nullfile || true sync rm $INITRDDIR/nullfile umount $INITRDDIR rmdir $INITRDDIR < $INITRDFILE gzip --best > $INITRDGZ rm -f $INITRDFILE umount $BOOTIMGDIR rmdir $BOOTIMGDIR syslinux KNOPPIX/boot.img } case "`basename $0`" in mountbootimage) mountbootimage ;; umountbootimage) umountbootimage ;; *) echo >&2 "ERR: called with unknown name `basename $0`" exit 1 ;; esac ------------------------------------------------------------------------ Last edited on July 25, 2004 11:37 pm. ------------------------------------------------------------------------ Edit | PageHistory | Diff | Info Sign In Copyright (c) 2003 Knoppix.net Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is located here . © Knoppix.net 2002 - 2003 KNOPPIX is a LinuxTAG project created by Klaus Knopper | This is not the official KNOPPIX website | Linux is a trademark of Linus Torvalds Search Knoppix.net