Difference between revisions of "Knoppix Remastering Howto"


From Knoppix Documentation Wiki
Jump to: navigation, search
m (Package Management)
 
(128 intermediate revisions by 55 users not shown)
Line 1: Line 1:
This is a guide that will show you how to remaster KNOPPIX. (Note: commands should appear on one line, so please maximize the window. If you have any comments/suggestions please post below.)
+
German translation → [[Knoppix Remastering Howto Deutsch]]
  
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 [[Knoppix Customizations]].
+
----
 +
This is a guide that will show you how to remaster KNOPPIX '''CD''' using the old "chroot method". The command lines within "Instructions" and "Remastering the ISO" are tested with '''Knoppix V7.0.4CD'''. You cannot use this HowTo for Knoppix '''DVD'''.
  
=System Requirements=
+
== Instructions ==
*CD-ISO
+
=== Setting up for Remastering ===
** 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)
+
* Boot from the ''Knoppix CD''
** 3 GB free on a '''Linux filesystem (ext2/3, xfs, etc.)''' formatted disk partition
+
* Open a terminal and type "su" to become root.
*DVD-ISO
+
* Configure your Internet connection. If you use DHCP, it should already be configured. ( Run '''ifconfig''' to check.)
** 5 GB free RAM + swap (for fullsized DVD)
+
* Find the partition you will use to work on and change the variable "PFAD" within the scripts as you need. In this example it is called '''/media/sda1'''. The partition should have a minimum of 5 GB free space for CD remaster and 20 GB for DVD remaster.
** 15 GB free on a '''Linux filesystem (ext2/3, xfs, etc.)''' formatted disk partition
+
* Make sure the partition is mounted!! (Run '''mount''' or '''df''' to check.)
 +
* The first script makes all needed preparations:
 +
#! /bin/sh
 +
# krhowto_1
 +
# Path to partition you will work on
 +
PFAD="/media/sda1"
 +
START=$(date +'%s')
 +
# Disable screensaver
 +
xscreensaver-command -exit
 +
# One sub-directory will be used for the Master-CD
 +
mkdir -p $PFAD/knx/master
 +
cd $PFAD/knx
 +
# You will need a swapfile
 +
dd if=/dev/zero of=swapfile bs=1M count=500
 +
mkswap swapfile ; swapon swapfile
 +
# Make a sub-directory for the source
 +
mkdir -p $PFAD/knx/source/KNOPPIX
 +
echo "Copy the KNOPPIX files to your source directory."
 +
echo "This will take a long time!"
 +
cp -rp /KNOPPIX/* $PFAD/knx/source/KNOPPIX
 +
# Additionally, copy the files to build the ISO later
 +
rsync -aH --exclude="KNOPPIX/KNOPPIX*" /mnt-system/* $PFAD/knx/master
 +
# gunzip inital RAM-disk
 +
mkdir -p $PFAD/knx/minirt/minirtdir
 +
cp $PFAD/knx/master/boot/isolinux/minirt.gz $PFAD/knx/minirt/
 +
cd $PFAD/knx/minirt/
 +
gunzip minirt.gz
 +
cd minirtdir
 +
cpio -imd --no-absolute-filenames < ../minirt
 +
# Enable screensaver
 +
su knoppix -c "xscreensaver -nosplash &"
 +
echo -e "\nFinished! Used time: $(expr $(expr $(date +'%s') - $START) / 60) min. \
 +
  and $(expr $(expr $(date +'%s') - $START) % 60) sec."
  
=Instructions=
+
=== Setup the environment for chroot ===
==Setting up for Remastering==
+
* Use this script to build the chroot environment:
# Boot from the ''Knoppix CD''
+
#! /bin/sh
# Open a root shell:
+
# krhowto_2
#* Menu: Kmenu->Knoppix->Root Shell
+
# Path to partition you will work on
#* Note: All commands below are run from this root shell.
+
PFAD="/media/sda1"
# Configure your Internet connection (we'll need this later). If you use DHCP, it should already be configured.
+
# To use the Internet add your nameserver into the chroot folder
#* Note: Run '''ifconfig''' to check.
+
cp /etc/resolv.conf $PFAD/knx/source/KNOPPIX/etc/resolv.conf
# 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
+
# Allow X-based programs in chroot
# Mount the partition:
+
[ -e $PFAD/knx/source/KNOPPIX/home/knoppix/.Xauthority ] \
#*<pre>mount -rw /dev/hda1 /mnt/hda1</pre>
+
    && rm $PFAD/knx/source/KNOPPIX/home/knoppix/.Xauthority
#* Note: Make sure that it is read/write or you will get errors when you later chroot. To check: run '''mount'''
+
  cp /home/knoppix/.Xauthority $PFAD/knx/source/KNOPPIX/home/knoppix
# Create a root directory to work in -- if you put all your files here it will be easy to clean up
+
chown knoppix:knoppix $PFAD/knx/source/KNOPPIX/home/knoppix/.Xauthority
#* <pre>mkdir /mnt/hda1/knx</pre>
+
# prepare enviroment for chroot
# If you don't have 1 GB RAM ('''cat /proc/meminfo''' (physical+swap)) then you will need a swapfile:
+
mount --bind /dev $PFAD/knx/source/KNOPPIX/dev
#* <pre><nowiki>cd /mnt/hda1/knx
+
mount -t proc proc $PFAD/knx/source/KNOPPIX/proc
dd if=/dev/zero of=swapfile bs=1M count=750
+
mount -t sysfs sysfs $PFAD/knx/source/KNOPPIX/sys
mkswap swapfile
+
mount --bind /dev/pts $PFAD/knx/source/KNOPPIX/dev/pts
swapon swapfile</nowiki></pre>
+
mount --bind /tmp $PFAD/knx/source/KNOPPIX/tmp
# Make 2 directories, one for your new Master CD, one for the source, on a disk partition. Also, make additional directories under these named KNOPPIX:
+
#* <pre><nowiki>mkdir -p /mnt/hda1/knx/master/KNOPPIX
+
mkdir -p /mnt/hda1/knx/source/KNOPPIX</nowiki></pre>
+
# Now, copy the KNOPPIX files to your source directory :
+
#* <pre><nowiki>cp -Rp /KNOPPIX/* /mnt/hda1/knx/source/KNOPPIX</nowiki></pre>
+
#* Note: This will take a long time (you are copying 2GB).  Warning: you will be tempted to replace this copy command with a much faster procedure: create an empty directory, then use unionfs to merge the empty directory with /KNOPPIX in order to create the read-write copyHowever, as of Knoppix 4.0.2, there is a bug in unionfs that causes this faster procedure to fail.  For now, stick with the copy-command shown above.
+
# Additionally, copy the 'boot' folder from your cdrom - you'll need these files to build the ISO later.
+
#* <pre><nowiki>cp -ar /cdrom/boot /mnt/hda1/knx/master/boot</nowiki></pre>
+
# Copy the main HTML page for the startup page:
+
#* <pre><nowiki>cp /cdrom/index.html /mnt/hda1/knx/master/</nowiki></pre>
+
# Copy everything necessary files except the ~700 Mb KNOPPIX file.
+
#* < 3.4:
+
#** <pre><nowiki>cd /cdrom/KNOPPIX && find . -size -10000k -type f -exec cp -p --parents '{}' /mnt/hda1/knx/master/KNOPPIX/ \;</nowiki></pre>
+
#* >= 3.4:
+
#** <pre><nowiki>cd /cdrom && find . -size -10000k -type f -exec cp -p --parents '{}' /mnt/hda1/knx/master/ \;</nowiki></pre>
+
#* for the DVD Version you have to use -size -15000k and copy the KNOPPIX2 folder like this
+
#** cp /cdrom/KNOPPIX/KNOPPIX2 /mnt/hda1/knx/master/KNOPPIX/
+
# Now you can "chroot" into the copied KNOPPIX:
+
#* <pre><nowiki>chroot /mnt/hda1/knx/source/KNOPPIX</nowiki></pre>
+
# If you see errors regarding <tt>/dev/null</tt>, see the [[#Common Problems|common problems]] section
+
You are now chrooted. "/" is actually "/mnt/hda1/knx/source/KNOPPIX"
+
  
==Working in the Chroot Environment==
+
<center>[[#top|Top]]</center>
Remember that anything you do or create in the chrooted environment will get burned to the CD.  If you make any changes (e.g,. to the APT configuration, proxy settings, etc.), make a note to back the changes out before remastering.
+
===Internet Access===
+
To use the Internet you need to mount /proc:
+
mount -t proc /proc proc
+
(You get a warning - "warning: can't open /etc/fstab: No such file or directory" but it still mounts)
+
and edit <tt>/etc/resolv.conf</tt> to add your nameserver or exit the chroot and copy the outer <tt>resolv.conf</tt> into the chroot folder:
+
cp /etc/dhcpc/resolv.conf /mnt/hda1/knx/source/KNOPPIX/etc/dhcpc/resolv.conf
+
(proxies (a.k.a. doing it at work): you can type "export http_proxy=http://your.proxy.com:<port>")<BR>
+
To check your chrooted internet connection,
+
ping google.com
+
(if ICMP is barred at some corporate firewall or something then try "lynx http://www.google.com" and see if you get the page -after a cookie "allow")
+
 
+
===SMB access===
+
Also change smb.conf to your MS group if you want smbd support (MSHOME is XP Home ed. usually, and WORKGROUP is 9x Windows)
+
===APT===
+
Update your package list with '''apt-get update'''.
+
<blockquote>Note: If ''''apt-get update''' fails with "FATAL -> Could not set non-blocking flag Bad file descriptor", you need to make sure your chrooted environment is mounted without the "nodev" option. (see above where it talks about the /dev/null errors when entering the chroot environment for the first time)</blockquote>
+
<blockquote>'''Warning''': apt-get upgrade is a ''BAD IDEA''. It will, quite probably, render your KNOPPIX remaster unbootable, or broken in some way. A far safer method is to only upgrade packages as necessary.</blockquote>
+
 
+
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
+
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; however it does not exclude packages that are not installed.  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.
+
 
+
Or, you could use this command to get the qpkg-query speed with the non-installed packages not listed:
+
dpkg-query -W --showformat='${Installed-Size} ${Package} ${Status}\n' | grep -v deinstall | sort -n | awk '{print $1" "$2}'
+
It does the same thing as above, I assume.  I couldn't get the first one to work because I don't have dpkg-awk.
+
 
+
To remove a package (and all packages dependant on it), type this:
+
apt-get remove --purge ''name-of-package-to-remove''
+
To check for orphaned packages, type this:
+
deborphan
+
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
+
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
+
Now the good stuff.  If you wish to add a package, type this:
+
apt-get install '''name-of-package-to-install''
+
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 <tt>/''search-term''</tt>:
+
apt-cache search .* | sort | less
+
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
+
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
+
===User Settings===
+
User settings are in /etc/skel.  This directory will be copied to make new user home directories.
+
<blockquote>tip: don't put files in /root they will be only available (at runtime) in /KNOPPIX/root</blockquote>
+
 
+
Note that the default user 'knoppix' is not created by adduser(1), thus /etc/skel is not copied completely but rather selectively.  That is, to make a file .xyrc appear in /home/knoppix, it is not sufficient to place it in /etc/skel.  One possibility is to extend the code in /etc/X11/Xsession.d/45xsession which is responsible for filling /home/knoppix.
+
 
+
===Autorunning Programs===
+
When you want to autorun some programs, one can create a script and put it in the directory <tt>/etc/rc5.d/</tt> (This only loads items before X loads).  Read up on the SysV init process for more possibilities.
+
 
+
==KNOPPIX Autoconfiguration==
+
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
+
* All boot parameters obtain default values in this file.  That is, to switch from 'kde' to 'twm' as default desktop just search for the place where 'kde' is provided as default value (variable DESKTOP, IIRC).  Similarly for example the default language can be changed.
+
 
+
==X Session Configuration==
+
When testing X-based programs, you will have to
+
export DISPLAY=localhost:0.0
+
which will allow you to connect to your normal X session.  Alternately (if you need to test window managers), you can create a nested X session.  Outside of the chroot, run
+
Xnest -ac :1
+
Within the chroot, set your DISPLAY variable
+
export DISPLAY=localhost:1
+
 
+
Interesting stuff in /etc/init.d/xsession :
+
* it ALSO sets background as /usr/local/lib/knoppix.gif
+
 
+
==Leaving the Chroot==
+
If you mounted it, you'll need to unmount /proc - very important!
+
umount /proc
+
Press '''CTRL+D''' to leave being chrooted.
+
 
+
==Remastering the ISO==
+
We've finished customizing and ready to burn!
+
First do some cleanup:
+
* remove any .bash_history files, tmp files, etc.
+
* back out any changes you don't want burned back to the disc
+
* <pre>rm -rf /mnt/hda1/knx/source/KNOPPIX/.rr_moved</pre>
+
 
+
===KNOPPIX Compressed Image===
+
Now we'll make the big <tt>KNOPPIX</tt> file which is an ISO 9660 filesystem compressed for use by the <tt>cloop</tt> driver:
+
mkisofs -R -U -V "KNOPPIX.net filesystem" -publisher "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.  Note that, to run <tt>create_compressed_fs</tt>, you'll need to have enough space to store the entire ISO in RAM/swap.  Ensure you have at least 800M of free space before starting.
+
 
+
In Knoppix 3.4 the <tt>create_compressed_fs</tt> 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).
+
 
+
===Live CD ISO===
+
If all went well, onto making the final CD-ROM Image:
+
cd /mnt/hda1/knx/master'''
+
find -type f -not -name md5sums -not -name boot.cat -not -name isolinux.bin \
+
    -exec md5sum '{}' \; > KNOPPIX/md5sums
+
(this will update the md5 hashes of the files included in the ISO, used for integrity checking) Now to burn the image; for Knoppix <= 3.3:
+
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
+
for Knoppix >= 3.4 or other isolinux based distributions:
+
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 <tt>/mnt/hda1/knx/knoppix.iso</tt>)
+
 
+
Burn the ISO using your favorite tools, and you're ready!
+
 
+
=Tips=
+
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.
+
 
+
==Package Management==
+
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 details 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 `< topurge `
+
and you're all done.
+
COLUMNS=200 dpkg -l |grep ^rc |awk '{print $2} ' | xargs dpkg -P
+
is a one-line version of this. Also use
+
deborphan | xargs dpkg -P .
+
 
+
==Alternatives for Low-Memory Machines==
+
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 [http://projects.openoffice.nl/downloads/compressloop/]
+
* Quozl's port of compressloop for Knoppix 3.4 [http://quozl.linux.org.au/compressloop-1.9-64bit.c]
+
* Quozl's distributed compressloop (use more than one processor to speed things up) [http://quozl.linux.org.au/knoppix/compressloop/] or [http://quozl.netrek.org/knoppix/compressloop/]
+
* Justin's patch [http://s.bouncybouncy.net/~justin/code/] (link broken) I also just wrote a distributed cloop compressor(or for smp)  It's in that same directory.
+
 
+
==Test CD Image Without Burning a 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 [[Hd BasedHowTo]].
+
 
+
If you don't have an extra partition or you don't want to do so much for it, you can use Qemu ( see [http://fabrice.bellard.free.fr/qemu/] ) with the ISO image like this:
+
qemu -m 128 -cdrom /temp/knoppix-custom.iso -boot d -user-net
+
You even do not have to build a hard disk image before, just install Qemu and try this. Amazing!
+
 
+
==Test remastered version without creating cloop file/iso==
+
i use a setup similar to knoppix terminal server to test the remastered files without having to recreate a
+
cloop image every time: the remastered files live in an ext2 filesytem in a loopfile (knoppix_loop) mounted rw (this is where i chroot in). when i want to test the current setup, i have another machine network boot and use the files from the loopfile directly (needs another miniroot.gz). See [[User:Ml#dev_setup]]
+
 
+
If you want to use only one machine, you'll have to reboot (or use qemu) and use the "loopfile" and "fromhd" cheatcodes (see [[User:Ml#miniroot_changes]]). For example, this is what my grub boot entry looks like:
+
 
+
<pre>
+
title          Remastered Knoppix
+
root            (hd0,0)
+
kernel          /boot/myknoppix/vmlinuz fromhd=/dev/hda4 loopfile=/samba/share/isos/knoppix_loop lang=us ramdisk_size=100000 init=/etc/init apm=power-off nomce vga=791 quiet BOOT_IMAGE=knoppix
+
initrd          /boot/myknoppix/miniroot.gz
+
</pre>
+
 
+
== Booting Knoppix images with GRUB==
+
* First copy /boot off 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).
+
* for Knoppix <= 3.3, 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
+
* for Knoppix >= 3.4 or other isolinux based distributions:
+
title KNOPPIX
+
        root  (hd0,0)
+
        kernel /boot.knoppix/isolinux/linux 2 fromhd=/dev/hda4 lang=us
+
        initrd /boot.knoppix/isolinux/minirt.gz
+
* notice the fromhd parameter: it's the location of the /KNOPPIX directory
+
* reboot and have fun.
+
 
+
==Helpful Scripts==
+
----
+
This is the recommended directory layout for remastering KNOPPIX:
+
. (invoke ../remaster from here)
+
|-- master (invoke ../../[[u]]mountbootimage 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 <mh+knoppix-remaster@zugschlus.de>
+
# License: GPL V2
+
 
   
 
   
ROOT="$PWD"
+
=== Working in the Chroot Environment ===
SOURCE="$ROOT/source/KNOPPIX"
+
* Now you can "chroot" into the copied KNOPPIX:
MASTER="$ROOT/master"
+
  chroot /media/sda1/knx/source/KNOPPIX
CLOOPTARGET="$ROOT/master/KNOPPIX/KNOPPIX"
+
* Remember that anything you do or create in the chrooted environment will get burned to the CD.
TARGET="$ROOT"
+
* Within the chroot you can also start X-based programs from command line of the terminal.
EXCLUDELIST="$ROOT/source/excludelist"
+
* Type "su knoppix" to become user knoppix; use "Strg D" to be root again.
+
* Update your package list with: '''apt-get update'''
rm -rf $SOURCE/.rr_moved
+
** '''Warning''': apt-get upgrade is a ''BAD IDEA''. It will, quite probably, render your KNOPPIX remaster unbootable, or broken in some way. A far safer method is to only upgrade packages as necessary.
+
**Before you can add stuff, you will probably need to remove some packages.
cd $SOURCE
+
* To get a list of packages installed, you can use [http://www.wp-schulz.de/scripte/kn-what-script kn-what] to get lists sorted by size etc.
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.
+
=== Leaving the Chroot ===
<!-- lines starting with space a preformatted -->
+
* Press '''CTRL+D''' to leave being chrooted; then use this schript:
  #!/bin/bash -x
+
  #! /bin/sh
  # This script will loop-mount boot floppy and initrd image
+
  # krhowto_3
  # Copyright (C) 2004 by Marc Haber <mh+knoppix-remaster@zugschlus.de>
+
  # Path to partition you will work on
# License: GPL V2
+
  PFAD="/media/sda1"
unset CDPATH || true
+
  for i in dev/pts proc sys dev tmp; do
+
  umount $PFAD/knx/source/KNOPPIX/$i
# if not root, re-invoke self as root
+
if [[ "`id -u`" -ne 0 ]]; then
+
  export LOCUSER="$USER"
+
export LOCHOME="$HOME"
+
if [[ "${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 "$BOOTIMGFILE" ]]; then
+
echo >&2 "ERR: no $BOOTIMGFILE found"
+
exit 1
+
fi
+
+
  for nofile in $BOOTIMGDIR $INITRDGZ $INITRDFILE $INITRDDIR; do
+
if [[ -e "$nofile" ]]; then
+
echo >&2 "ERR: $nofile already exists"
+
exit 1
+
fi
+
 
  done
 
  done
 +
sed -i '2,$d' $PFAD/knx/source/KNOPPIX/etc/resolv.conf
 
   
 
   
mkdir -p $BOOTIMGDIR
+
=== Changes outside from chroot enviroment ===
mount -o loop,uid=$LOCUSER -t $BOOTIMGFS $BOOTIMGFILE $BOOTIMGDIR
+
* If you want another way to start with Knoppix, make changes in '/media/sda1/knx/master/boot/isolinux/isolinux.cfg':
+
** for example replace all 'tz=localtime' with 'tz=America/New_York'
< $INITRDGZ gunzip > $INITRDFILE
+
* You can append in this file cheatcodes, which you need all the time:
mkdir -p $INITRDDIR
+
** for example write 'no3d' (without ' ') to each Append line, if you don't like compiz 3d
mount -o loop -t $INITRDFS $INITRDFILE $INITRDDIR
+
* Read '''knoppix-cheatcodes.txt'''. You can find the newest version of this file on the [http://www.knopper.net/knoppix-mirrors/ Mirrors].
}
+
* In '/media/sda1/knx/source/KNOPPIX/etc/X11/Xsession.d/45knoppix' you can find, which wallpaper Knoppix uses or which startup-sound.
+
* In '/media/sda1/knx/source/KNOPPIX/etc/init.d/knoppix-halt' you'll find which sound you hear during shutdown.
umountbootimage() {
+
* Create a file '/media/sda1/knx/master/KNOPPIX/knoppix.sh' in order to start additional services.
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
+
  
==Tips around apt-get to install/update/remove applications==
+
<center>[[#top|Top]]</center>
(by gnarvaja)
+
* If you booted from CD, even on a HD install (example: Pivot Install) instead of copying the original CD and KNOPPIX directory to the HD, you can use them directly from their mount points.
+
* Another alternative is to mount an ISO image of the original CD as a loop device and mount the KNOPPIX image as a '''cloop''' device. You will save close to 2GB of space. Script to mount from an ISO image:
+
  
  #!/bin/bash
+
== Remastering the ISO ==
  # Assumes that the current directory is the working space
+
* We've finished customizing and ready to burn!
  # original.iso is an image of the CD we will be using as master
+
  #! /bin/sh
  mount -t iso9660 original.iso ./oldcd -o ro,loop
+
  # krhowto_4
  # initialize the compressed loop device
+
  # Path to partition you will work on
  losetup /dev/cloop1 ./oldcd/KNOPPIX/KNOPPIX
+
  PFAD="/media/sda1"
  mount -t iso9660 /dev/cloop1 ./KNOPPIX -o ro,loop
+
START=$(date +'%s')
 +
# Disable screensaver
 +
xscreensaver-command -exit
 +
# Build new inital RAM-disk
 +
cd $PFAD/knx/minirt/minirtdir/
 +
find . | cpio -oH newc | gzip -9 > ../minirt.gz
 +
cp $PFAD/knx/minirt/minirt.gz $PFAD/knx/master/boot/isolinux/
 +
  # Make the big  compressed filesystem KNOPPIX
 +
  genisoimage -input-charset ISO-8859-15 -R -l -D -V KNOPPIX_FS -quiet \
 +
  -no-split-symlink-components -no-split-symlink-fields \
 +
  -hide-rr-moved -cache-inodes $PFAD/knx/source/KNOPPIX \
 +
  | /usr/sbin/create_compressed_fs -q -B 65536 -t 8 -L 9 \
 +
  -f $PFAD/knx/isotemp - $PFAD/knx/master/KNOPPIX/KNOPPIX
 +
  # Update the file hashes used by the "testcd" boot option
 +
cd $PFAD/knx/master ; find -type f -not -name \
 +
  sha1sums -not -name boot.cat -not \
 +
  -name isolinux.bin -exec sha1sum '{}' \; > KNOPPIX/sha1sums
 +
# Create new Knoppix ISO
 +
genisoimage -l -r -J -V "KNOPPIX" \
 +
  -b boot/isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 \
 +
  -boot-info-table -c boot/isolinux/boot.cat \
 +
  -o $PFAD/knx/remastered.iso $PFAD/knx/master
 +
# Enable screensaver
 +
su knoppix -c "xscreensaver -nosplash &"
 +
echo -e "\nFinished! Used time: $(expr $(expr $(date +'%s') - $START) / 60) min. \
 +
  and $(expr $(expr $(date +'%s') - $START) % 60) sec. \
 +
  \n\nThe new ISO is stored in '$PFAD/knx/remastered.iso' "
  
* Get '''apt-spy''' and use it to modify the sources.list file with the best mirrors for your particular region. This will speed up the downloading. Backup the original '''sources.list''' just in case.
+
<center>[[#top|Top]]</center>
* Another technique is to modify '''sources.list'''. Replace the string '''.de.''' in the ftp addresses (ftp.de.debian.org) with the code corresponding to your country. Examples: USA -> .us. (ftp.us.debian.org), Brazil -> .br. (ftp.br.debian.org). Check the Debian site for debian.org mirrors in your country.
+
* Remember to uncomment the '''linuxtag''' ftp addresses to get the latest and greatest from Knoppix
+
* Use '''apt-get update''' to get the lists with the latest releases and patches. Do not update a package if you don't need to, it may lead to the use of additional disk space (precious commodity when you want to keep everything below 700MB) and you may brake something else without knowing. Abuse the '''-s''' option to simulate the installation.
+
* Before doing the update, I modified my default releases to '''testing''', that means that the software I'll be using will have a good balance of stability and features. Knoppix uses '''unstable''' by default, which is too risky for my personal taste.
+
* Get '''[apt-get install] locale''' and configure it with the locales you are going to use. It will save lots of space when downloading applications with plenty of locale modules and localized manual pages.
+
* I use '''aptitude''' to get/remove applications, it is character based so it works with init 2. As you mark packages for install/update/removal, it will tell you how much disk space you will save/use, try to solve depencies problems and give you plenty control to fix them manually when possible.
+
* When installing applications it is likely that your '''/etc/rc?.d''' directories will have new entries, many of them unwanted or unplanned. Make sure you check them and remove the new entries based on your preferences. I usually leave '''/etc/rc2.d''' and '''/etc/rc5.d''' as close as the originals as possible and modify '''/etc/rc3.d''' and '''/etc/rc4.d''' to test new stuff. '''Example:''' You may want to have ntfs installed, but not necessarily running by default. Same with apache, mysql and many others.
+
* When removing/purging applications, they may leave behind non-empty directories. Usually this is announced by aptitude, apt-get or any other installation utilty. Make sure to check the messages and manually remove those directories.
+
* After you are done, '''aptitude''' may leave some files behind. Here's a clean up script I use:
+
  
# !/bin/bash
+
== Test CD Image Without Burning a CD ==
# Clean package files generated by aptitude
+
* kvm-qemu
  rm /var/log/aptitude
+
If your processor supports virtualization '''and''' it is enabled by the BIOS you can test the new ISO by kvm-qemu. Check for support by:
  rm /var/lib/apt/lists/*debian*
+
  egrep '(vmx|svm)' --color=always /proc/cpuinfo
  rm /var/lib/apt/lists/*knoppix*
+
If you get the result "vmx" type
 +
  modprobe kvm-intel
 +
otherwise if you get the result "svm" type
 +
  modprobe kvm-amd
 +
to load the kvm module. Now you can test the new ISO by
 +
kvm -m 512 -cdrom $PFAD/knx/remastered.iso
  
=Common Problems=
+
* VirtualBox
* [[Dev_null_permission_denied|/dev/null: Permission Denied]] Chroot problems accessing device files
+
VirtualBox can be used to test a newly generated ISO as well.
 +
----
  
=See also=
+
See also:
 +
* [http://www.wp-schulz.de/summary/summary-remaster Remaster Knoppix without chroot]
 +
* [http://www.wp-schulz.de/summary/summary-recombine Recombine Knoppix flash installation]
  
If my howto is too confusing, or you'd like a second opinion, check out charan's very nice remastering howto: http://gnubox.dyndns.org:8080/~sunil/knoppix.php.
+
<center>[[#top|Top]]</center>
Another Howto is at  http://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 debian's standard software installation tools. It is called mmkcdrom and part of the plugscript package: [http://rcswww.urz.tu-dresden.de/~holzhey/plugscript]
+
 
+
Yet another HOWTO, for shell freaks, is at http://quozl.linux.org.au/knoppix/
+
 
+
Be sure to check out the [http://knoppix.net/forum/viewforum.php?f=2 Knoppix Customization Forum] for ideas and help with remastering.
+
 
+
* If you want to add a custom kernel, check out the [[Knoppix Custom Kernel Howto]]
+
* There also a guide at O'Reilly on the same topic : [http://linux.oreillynet.com/lpt/a/4323 Using and Customizing Knoppix]
+
 
+
=Conclusion=
+
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=
+
Thanks to aay, charan, Tech2k, and #knoppix for some corrections and tips and ideas.  Feel free to edit or add to this howto.
+
Note about swap:<br>
+
  
=Translations=
+
Return to '''[[Main Page]] of the Wiki'''.
* German Version: [[Knoppix Remastering Howto Deutsch]]
+
* Spanish Version: [[Knoppix Remastering Howto Spanish]]  en español
+
* French Version: [[Knoppix Remastering Howto French]]
+
* Indonesian Version: [[Knoppix Remastering Howto Indonesian]]
+
* Russian Version: [[Knoppix Remastering Howto Russian]]
+
  
 
[[Category: Remastering Knoppix ]]
 
[[Category: Remastering Knoppix ]]

Latest revision as of 09:11, 3 May 2016

German translation → Knoppix Remastering Howto Deutsch


This is a guide that will show you how to remaster KNOPPIX CD using the old "chroot method". The command lines within "Instructions" and "Remastering the ISO" are tested with Knoppix V7.0.4CD. You cannot use this HowTo for Knoppix DVD.

Instructions

Setting up for Remastering

  • Boot from the Knoppix CD
  • Open a terminal and type "su" to become root.
  • Configure your Internet connection. If you use DHCP, it should already be configured. ( Run ifconfig to check.)
  • Find the partition you will use to work on and change the variable "PFAD" within the scripts as you need. In this example it is called /media/sda1. The partition should have a minimum of 5 GB free space for CD remaster and 20 GB for DVD remaster.
  • Make sure the partition is mounted!! (Run mount or df to check.)
  • The first script makes all needed preparations:
#! /bin/sh
# krhowto_1
# Path to partition you will work on
PFAD="/media/sda1"
START=$(date +'%s')
# Disable screensaver
xscreensaver-command -exit
# One sub-directory will be used for the Master-CD
mkdir -p $PFAD/knx/master
cd $PFAD/knx
# You will need a swapfile
dd if=/dev/zero of=swapfile bs=1M count=500
mkswap swapfile ; swapon swapfile
# Make a sub-directory for the source
mkdir -p $PFAD/knx/source/KNOPPIX
echo "Copy the KNOPPIX files to your source directory."
echo "This will take a long time!"
cp -rp /KNOPPIX/* $PFAD/knx/source/KNOPPIX
# Additionally, copy the files to build the ISO later
rsync -aH --exclude="KNOPPIX/KNOPPIX*" /mnt-system/* $PFAD/knx/master
# gunzip inital RAM-disk
mkdir -p $PFAD/knx/minirt/minirtdir
cp $PFAD/knx/master/boot/isolinux/minirt.gz $PFAD/knx/minirt/
cd $PFAD/knx/minirt/
gunzip minirt.gz
cd minirtdir
cpio -imd --no-absolute-filenames < ../minirt
# Enable screensaver
su knoppix -c "xscreensaver -nosplash &"
echo -e "\nFinished! Used time: $(expr $(expr $(date +'%s') - $START) / 60) min. \
  and $(expr $(expr $(date +'%s') - $START) % 60) sec."

Setup the environment for chroot

  • Use this script to build the chroot environment:
#! /bin/sh
# krhowto_2
# Path to partition you will work on
PFAD="/media/sda1"
# To use the Internet add your nameserver into the chroot folder
cp /etc/resolv.conf $PFAD/knx/source/KNOPPIX/etc/resolv.conf
# Allow X-based programs in chroot
[ -e $PFAD/knx/source/KNOPPIX/home/knoppix/.Xauthority ] \
   && rm $PFAD/knx/source/KNOPPIX/home/knoppix/.Xauthority
cp /home/knoppix/.Xauthority $PFAD/knx/source/KNOPPIX/home/knoppix
chown knoppix:knoppix $PFAD/knx/source/KNOPPIX/home/knoppix/.Xauthority
# prepare enviroment for chroot
mount --bind /dev $PFAD/knx/source/KNOPPIX/dev
mount -t proc proc $PFAD/knx/source/KNOPPIX/proc
mount -t sysfs sysfs $PFAD/knx/source/KNOPPIX/sys
mount --bind /dev/pts $PFAD/knx/source/KNOPPIX/dev/pts
mount --bind /tmp $PFAD/knx/source/KNOPPIX/tmp
Top

Working in the Chroot Environment

  • Now you can "chroot" into the copied KNOPPIX:
 chroot /media/sda1/knx/source/KNOPPIX
  • Remember that anything you do or create in the chrooted environment will get burned to the CD.
  • Within the chroot you can also start X-based programs from command line of the terminal.
  • Type "su knoppix" to become user knoppix; use "Strg D" to be root again.
  • Update your package list with: apt-get update
    • Warning: apt-get upgrade is a BAD IDEA. It will, quite probably, render your KNOPPIX remaster unbootable, or broken in some way. A far safer method is to only upgrade packages as necessary.
    • Before you can add stuff, you will probably need to remove some packages.
  • To get a list of packages installed, you can use kn-what to get lists sorted by size etc.

Leaving the Chroot

  • Press CTRL+D to leave being chrooted; then use this schript:
#! /bin/sh
# krhowto_3
# Path to partition you will work on
PFAD="/media/sda1"
for i in dev/pts proc sys dev tmp; do
  umount $PFAD/knx/source/KNOPPIX/$i
done
sed -i '2,$d' $PFAD/knx/source/KNOPPIX/etc/resolv.conf

Changes outside from chroot enviroment

  • If you want another way to start with Knoppix, make changes in '/media/sda1/knx/master/boot/isolinux/isolinux.cfg':
    • for example replace all 'tz=localtime' with 'tz=America/New_York'
  • You can append in this file cheatcodes, which you need all the time:
    • for example write 'no3d' (without ' ') to each Append line, if you don't like compiz 3d
  • Read knoppix-cheatcodes.txt. You can find the newest version of this file on the Mirrors.
  • In '/media/sda1/knx/source/KNOPPIX/etc/X11/Xsession.d/45knoppix' you can find, which wallpaper Knoppix uses or which startup-sound.
  • In '/media/sda1/knx/source/KNOPPIX/etc/init.d/knoppix-halt' you'll find which sound you hear during shutdown.
  • Create a file '/media/sda1/knx/master/KNOPPIX/knoppix.sh' in order to start additional services.
Top

Remastering the ISO

  • We've finished customizing and ready to burn!
#! /bin/sh
# krhowto_4
# Path to partition you will work on
PFAD="/media/sda1"
START=$(date +'%s')
# Disable screensaver
xscreensaver-command -exit
# Build new inital RAM-disk
cd $PFAD/knx/minirt/minirtdir/
find . | cpio -oH newc | gzip -9 > ../minirt.gz
cp $PFAD/knx/minirt/minirt.gz $PFAD/knx/master/boot/isolinux/
# Make the big  compressed filesystem KNOPPIX
genisoimage -input-charset ISO-8859-15 -R -l -D -V KNOPPIX_FS -quiet \
  -no-split-symlink-components -no-split-symlink-fields \
  -hide-rr-moved -cache-inodes $PFAD/knx/source/KNOPPIX \
  | /usr/sbin/create_compressed_fs -q -B 65536 -t 8 -L 9 \
  -f $PFAD/knx/isotemp - $PFAD/knx/master/KNOPPIX/KNOPPIX
# Update the file hashes used by the "testcd" boot option
cd $PFAD/knx/master ; find -type f -not -name \
  sha1sums -not -name boot.cat -not \
  -name isolinux.bin -exec sha1sum '{}' \; > KNOPPIX/sha1sums
# Create new Knoppix ISO
genisoimage -l -r -J -V "KNOPPIX" \
  -b boot/isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 \
  -boot-info-table -c boot/isolinux/boot.cat \
  -o $PFAD/knx/remastered.iso $PFAD/knx/master
# Enable screensaver
su knoppix -c "xscreensaver -nosplash &"
echo -e "\nFinished! Used time: $(expr $(expr $(date +'%s') - $START) / 60) min. \
  and $(expr $(expr $(date +'%s') - $START) % 60) sec. \
  \n\nThe new ISO is stored in '$PFAD/knx/remastered.iso' "
Top

Test CD Image Without Burning a CD

  • kvm-qemu

If your processor supports virtualization and it is enabled by the BIOS you can test the new ISO by kvm-qemu. Check for support by:

egrep '(vmx|svm)' --color=always /proc/cpuinfo

If you get the result "vmx" type

modprobe kvm-intel

otherwise if you get the result "svm" type

modprobe kvm-amd

to load the kvm module. Now you can test the new ISO by

kvm -m 512 -cdrom $PFAD/knx/remastered.iso
  • VirtualBox

VirtualBox can be used to test a newly generated ISO as well.


See also:

Top

Return to Main Page of the Wiki.