Difference between revisions of "Knoppix Remastering Howto"


From Knoppix Documentation Wiki
Jump to: navigation, search
Line 1: Line 1:
This is a guide that will show you how to remaster KNOPPIX. The command lines within "Instructions" and "Remastering the ISO" are tested with Knoppix V6.7.1CD. Please do not use old versions of Knoppix!
+
This is a guide that will show you how to remaster KNOPPIX using the old "chroot method". The command lines within "Instructions" and "Remastering the ISO" are tested with Knoppix V6.7.1CD. Please do not use old versions of Knoppix!
 
=Instructions=
 
=Instructions=
 
==Setting up for Remastering==
 
==Setting up for Remastering==
 
* Boot from the ''Knoppix CD''
 
* Boot from the ''Knoppix CD''
* Open a root shell:  Menu->Accessories->Root Shell
+
* Open a terminal and type "su" to become root.
* Configure your Internet connection. If you use DHCP, it should already be configured.
+
* Configure your Internet connection. If you use DHCP, it should already be configured. ( Run '''ifconfig''' to check.)
** Note: 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.
* Find the partition you will use to work on. In this example it is called '''sda1''' . The partition should have a minimum of 5 GB free space.
+
* The first script makes all needed preparations:
* Mount the partition:
+
   #! /bin/sh
   mount -rw /dev/sda1 /media/sda1
+
  # Path to partition you will work on
* Note: Make sure that it is read/write or you will get errors when you later chroot. To check: run '''mount'''
+
  PFAD="/media/sda1"
* You need a root directory '''/knx''' to work in; if you put all your files here it will be easy to clean up. Two sub-directories will be used, one for the Master-CD.
+
  START=$(date +'%s')
   mkdir -p /media/sda1/knx/master
+
  # Disable screensaver
* You will need a swapfile:
+
  xscreensaver-command -exit
  cd /media/sda1/knx
+
  # 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
 
   dd if=/dev/zero of=swapfile bs=1M count=500
 
   mkswap swapfile ; swapon swapfile
 
   mkswap swapfile ; swapon swapfile
* Make a sub-directory for the source:
+
  free -m
   mkdir -p /media/sda1/knx/source/KNOPPIX
+
  # Make a sub-directory for the source
* Now, copy the KNOPPIX files to your source directory :
+
   mkdir -p $PFAD/knx/source/KNOPPIX
** Note: This will take a long time (you are copying 2.4 GB).
+
  echo "Copy the KNOPPIX files to your source directory."
   cp -rp /KNOPPIX/* /media/sda1/knx/source/KNOPPIX
+
  echo "This will take a long time!"
* Additionally, copy the files to build the ISO later:
+
   cp -rp /KNOPPIX/* $PFAD/knx/source/KNOPPIX
   rsync -aH --exclude="KNOPPIX/KNOPPIX" /mnt-system/* /media/sda1/knx/master
+
  echo "rsync"
* Setup the environment for chroot:
+
  # Additionally, copy the files to build the ISO later
   mount --bind /dev /media/sda1/knx/source/KNOPPIX/dev
+
   rsync -aH --exclude="KNOPPIX/KNOPPIX" /mnt-system/* $PFAD/knx/master
  mount -t proc proc /media/sda1/knx/source/KNOPPIX/proc
+
  # gunzip inital RAM-disk
   mount -t sysfs sysfs /media/sda1/knx/source/KNOPPIX/sys
+
   mkdir -p $PFAD/knx/minirt/minirtdir
* To use the Internet you need to edit 'resolv.conf' to add your nameserver or  copy the outer 'resolv.conf' into the chroot folder:
+
  cp $PFAD/knx/master/boot/isolinux/minirt.gz $PFAD/knx/minirt/
   rm -f /media/sda1/knx/source/KNOPPIX/etc/resolv.conf
+
  cd $PFAD/knx/minirt/
   cp /etc/resolv.conf /media/sda1/knx/source/KNOPPIX/etc/resolv.conf
+
  gunzip minirt.gz
* In case of proxies (a.k.a. doing it at work) you can type:
+
  cd minirtdir
   export http_proxy="http://myProxy:8080"
+
  cpio -imd --no-absolute-filenames < ../minirt
   alternative
+
   # Enable screensaver
   export http_proxy="http://username:password@myProxy:8080"
+
  su knoppix -c "xscreensaver -nosplash &"
* Also change smb.conf to your MS group if you want smbd support (MSHOME is XP Home ed. usually, and WORKGROUP is 9x Windows)
+
  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
 +
  # 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
 +
 
 
==Working in the Chroot Environment==
 
==Working in the Chroot Environment==
 
* Now you can "chroot" into the copied KNOPPIX:
 
* Now you can "chroot" into the copied KNOPPIX:
 
   chroot /media/sda1/knx/source/KNOPPIX
 
   chroot /media/sda1/knx/source/KNOPPIX
 
* Remember that anything you do or create in the chrooted environment will get burned to the CD.
 
* 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'''
 
* 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.
 
** '''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.
 
**Before you can add stuff, you will probably need to remove some packages.
* To get a list of packages installed, type this:
+
* To get a list of packages installed, you can use [http://www.wp-schulz.de/knoppix/kn-script.html#kn-what kn-what] to get lists sorted by size etc.
  dpkg-query -l
+
 
** Hint: Use [http://www.wp-schulz.de/knoppix/kn-script.html#kn-what kn-what] to get lists of installed packages sorted by size etc.
+
* 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 exact name of packages to install?
+
  apt-cache search "searchterm"
+
* When you're done removing and adding packages, a good way to clean up is by typing this:
+
  apt-get clean
+
 
==Leaving the Chroot==
 
==Leaving the Chroot==
* Press '''CTRL+D''' to leave being chrooted.
+
* Press '''CTRL+D''' to leave being chrooted; then use this schript:
   umount /media/sda1/knx/source/KNOPPIX/dev
+
   #! /bin/sh
  umount /media/sda1/knx/source/KNOPPIX/proc
+
  # Path to partition you will work on
   umount /media/sda1/knx/source/KNOPPIX/sys
+
  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==
 
==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':
 
* If you want another way to start with Knoppix, make changes in '/media/sda1/knx/master/boot/isolinux/isolinux.cfg':
Line 73: Line 88:
 
* In '/media/sda1/knx/source/KNOPPIX/etc/init.d/knoppix-halt' you'll find which sound you hear during shutdown.
 
* 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.
 
* Create a file '/media/sda1/knx/master/KNOPPIX/knoppix.sh' in order to start additional services.
* Perhaps you like Knoppix with a graphical [http://www.wp-schulz.de/rettung.html#presc Boot-Menü].
 
 
=Remastering the ISO=
 
=Remastering the ISO=
* We've finished customizing and ready to burn! First do some cleanup in '/media/sda1/knx/source/KNOPPIX/tmp/'
+
* We've finished customizing and ready to burn!
==KNOPPIX Compressed Image==
+
  #! /bin/sh
* Now we'll make the big KNOPPIX file which is an ISO 9660 filesystem compressed for use by the cloop driver.
+
  Path to partition you will work on
** Hint: Copy and paste each of the three following command lines in the root shell in a single line.
+
  PFAD="/media/sda1"
* <code>genisoimage -R -U -V "KNOPPIX.net filesystem" -publisher "KNOPPIX www.knoppix.net" -no-bak -quiet /media/sda1/knx/source/KNOPPIX | /usr/sbin/create_compressed_fs -B 65536 -f /media/sda1/knx/isotemp - /media/sda1/knx/master/KNOPPIX/KNOPPIX</code>
+
  START=$(date +'%s')
==Live CD ISO==
+
  # Disable screensaver
* First, update the file hashes used by the "testcd" boot option:
+
  xscreensaver-command -exit
* <code>cd /media/sda1/knx/master ; find -type f -not -name sha1sums -not -name boot.cat -not -name isolinux.bin -exec sha1sum '{}' \; >> KNOPPIX/sha1sums</code>
+
  # Build new inital RAM-disk
* Now to create the ISO:
+
  cd $PFAD/knx/minirt/minirtdir/
* <code>genisoimage -l -r -J -V "KNOPPIX" --publisher "KNOPPIX www.knoppix.net" -b boot/isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table -c boot/isolinux/boot.cat -o /media/sda1/knx/remasterd.iso /media/sda1/knx/master</code>
+
  find . | cpio -oH newc | gzip -9 > ../minirt.gz
* The ISO is stored in '/media/sda1/knx/remastered.iso'
+
  cp $PFAD/knx/minirt/minirt.gz $PFAD/knx/master/boot/isolinux/
** Hint: Test the ISO for example with VirtualBox before burning with your favorite tools.
+
  # 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 \
 +
    -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/remasterd.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' "
  
 
* End of '''revised version''' of this HowTo
 
* End of '''revised version''' of this HowTo
Line 93: Line 126:
 
==Autorunning Programs==
 
==Autorunning Programs==
 
When you want to autorun some programs, one can create a script and put the script in /etc/init.d, then add it to the SERVICES variable in /etc/rc.local.
 
When you want to autorun some programs, one can create a script and put the script in /etc/init.d, then add it to the SERVICES variable in /etc/rc.local.
 
 
''For X-programs consider <tt>/home/knoppix/.kde/Autostart</tt>
 
''For X-programs consider <tt>/home/knoppix/.kde/Autostart</tt>
  
 
==Editing the KNOPPIX auto-configuration script==
 
==Editing the KNOPPIX auto-configuration script==
 
You can find a lot of interesting information about how KNOPPIX auto-configures your system by looking in '/etc/init.d/knoppix-autoconfig' and '/etc/X11/Xsession.d/45knoppix' scripts.
 
You can find a lot of interesting information about how KNOPPIX auto-configures your system by looking in '/etc/init.d/knoppix-autoconfig' and '/etc/X11/Xsession.d/45knoppix' scripts.
 
==X Session Configuration==
 
When working with X-based programs you will have to make sure that your display is set appropriately. You can do this manually when remastering KNOPPIX.
 
 
===Starting X-based programs===
 
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
 
 
==Changing the boot graphic, boot message, and startup script text==
 
==Changing the boot graphic, boot message, and startup script text==
 
While you are in the chroot environment you can easily change the boot messages, the boot graphic, and the default KDE background graphic.
 
While you are in the chroot environment you can easily change the boot messages, the boot graphic, and the default KDE background graphic.
Line 136: Line 157:
 
===Changing the startup script text===
 
===Changing the startup script text===
 
The 'startup script text' is the text that you see after the initial boot screen, while Knoppix loads and configures your system. You can change as much of this text as you please. You can even add addition lines to the script; however, it is recommended that you don't play with this file. Limiting yourself to editing the 'Welcome to KNOPPIX' message is a good idea.  
 
The 'startup script text' is the text that you see after the initial boot screen, while Knoppix loads and configures your system. You can change as much of this text as you please. You can even add addition lines to the script; however, it is recommended that you don't play with this file. Limiting yourself to editing the 'Welcome to KNOPPIX' message is a good idea.  
 
#To access the files in minirt.gz, start by copying minirt.gz from master/boot/isolinux to an empty temp directory.
 
#In the temp directory do the following:
 
#* <pre><nowiki>gunzip minirt.gz</nowiki></pre>
 
#* <pre><nowiki>mkdir minirtdir</nowiki></pre>
 
#* <pre><nowiki>cd minirtdir</nowiki></pre>
 
#* <pre><nowiki>cpio -ivu --no-absolute-filenames < ../minirt</nowiki></pre>
 
#You should now have the minirt directory tree under minirtdir .  Make your mods to files.
 
#To wrap it backup up, in minirtdir:
 
#* <pre><nowiki>find . | cpio -oH newc | gzip -9 > ../minirt.gz</nowiki></pre>
 
#Copy minirt.gz back to master/boot/isolinux
 
  
 
==How to add new device driver to KNOPPIX==
 
==How to add new device driver to KNOPPIX==

Revision as of 22:35, 31 January 2012

This is a guide that will show you how to remaster KNOPPIX using the old "chroot method". The command lines within "Instructions" and "Remastering the ISO" are tested with Knoppix V6.7.1CD. Please do not use old versions of Knoppix!

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.
  • The first script makes all needed preparations:
 #! /bin/sh
 # 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
 free -m
 # 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
 echo "rsync"
 # 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
 # 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

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
 # 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.

Remastering the ISO

  • We've finished customizing and ready to burn!
 #! /bin/sh
 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 \
   -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/remasterd.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' "
  • End of revised version of this HowTo

Old stuff of this HowTo

  • Be aware, all in this chapter may work or not - I didn't tested it!

Autorunning Programs

When you want to autorun some programs, one can create a script and put the script in /etc/init.d, then add it to the SERVICES variable in /etc/rc.local. For X-programs consider /home/knoppix/.kde/Autostart

Editing the KNOPPIX auto-configuration script

You can find a lot of interesting information about how KNOPPIX auto-configures your system by looking in '/etc/init.d/knoppix-autoconfig' and '/etc/X11/Xsession.d/45knoppix' scripts.

Changing the boot graphic, boot message, and startup script text

While you are in the chroot environment you can easily change the boot messages, the boot graphic, and the default KDE background graphic.

Changing the boot graphic

The 'boot graphic' is the first image you see when the CD or DVD boots. It looks similar to ASCII art and it is normally something flashy that says 'Knoppix'. You can change this to be any graphic that you please, but you must use a 640x400 graphic that has only 16 colors.

  1. Change to the /mnt/sda1/knx/master/boot directory. Swap '/mnt/sda1/' for whatever disk you are using.
    • cd /mnt/sda1/knx/master/boot/isolinux
  2. Back up your old logo in case you break things.
    • mv logo.16 logo.16.backup
  3. Make a 640x400 pixel 16 color graphic and save it as a GIF, e.g. 'logo.16.gif'. GIMP can easily do this. Note, you can use a graphic that originally had more than 16 colors, but it is critical that you convert the graphic to 16 colors before doing the next step.
  4. Convert the GIF to lss16 using the tools included on the Knoppix CD.
    • giftopnm < 640x400x16.gif > logo.ppm
    • ppmtolss16 <logo.ppm > logo.16

Changing the boot message

The 'boot message' is the message that you see under the 'boot graphic' on the initial screen when the Knoppix CD or DVD loads. It normally says something along the lines of Knoppix with the version number and includes a link to the Knoppix website. You can change this text to be whatever you please, but you shouldn't add too much text or it will make the boot screen look funny. Restricting yourself to a single line of text that is no larger than the default one is a good idea.

  1. Change to the /mnt/sda1/knx/master/boot directory. Swap '/mnt/sda1/' for whatever disk you are using.
    • cd /mnt/sda1/knx/master/boot/isolinux
  2. Back up your old message in case you break things.
    • cp boot.msg boot.msg.backup
  3. Edit the message with a text editor. You'll see at the top of the message that it shows the graphic. Don't change this text, just the line under.
    • vi boot.msg

Changing the startup script text

The 'startup script text' is the text that you see after the initial boot screen, while Knoppix loads and configures your system. You can change as much of this text as you please. You can even add addition lines to the script; however, it is recommended that you don't play with this file. Limiting yourself to editing the 'Welcome to KNOPPIX' message is a good idea.

How to add new device driver to KNOPPIX

Recently in a client project, I added the Digital Persona’s finger print driver to the Knoppix 5.1 distribution as an embedded solution to this project. This is a typical case where both the kernel level driver and the user level drivers and libraries are involved.

Most of the Knoppix books and online documentation have documented about how to keep a persistent storage of user configuration and user data. But those persistent configuration only saves the data in /home and /etc directories. If you have added kernel level drivers and/or other system libraries which are not in above two directories, you have to save the file images as a whole right after the boot. The saved file image can be big and may not what you want as a regular usage model. If you are building a customed Knoppix image for a long term solution, definitely you want to remaster the Knoppix to make the new drives be a permanent part of it.

The Digital Persona’s OneTouch SDK for their finger print scanner driver comes with a kernel level driver source code, plus a set of user level application libraries, as well as a sample test application. The SDK do not have a ready made binary for Debian or Knoppix. So I have to compile it from the source SDK. However, the CD version of Knoppix 5.1 do not even come with the source include header files to compile a kernel level driver. So I have to compile it under the DVD version of the Knoppix 5.1 and copy the compiled binary to the CD version of Knoppix 5.1 to do testing and remastering. The steps I have tried to make it work under Knoppix are as follows:

1. First compile the driver under DVD version of the Knoppix. Change the source code build scripts so that the include files and library path are matching what we have in Knoppix. The details are specific to the OneTouch SDK itself. If you are interested about this detail, write to me.

2. Install the just built kernel driver, the user libraries to their regular location as we will show in following step 4. And then build and run their sample applications per Digital Persona’s instruction. This proves that the basic kernel module build steps are built correctly and the user level libraries are working properly in a standard installation. This is important before we moved to chroot environment to make this changes permanent to our remastered Knoppix.

3. Then I followed the Knoppix remastering instructions documented in the book of “Live Linux CD” by Christoper Negus.

4. In the above remastering instructions, there is a step to update all the Debian packages and other software under the chroot environment. It is at this step that I re-run the drivers installation steps like I have done in above step 2 in the real root environment. In this particular case, it is make a directory and copy the kernel module file mod_usbdpfp.ko to that directory as follows:

mkdir /lib/modules/2.6.19/kernel/drivers/biometric cp mod_usbdpfp.ko /lib/modules/2.6.19/mod_usbdpfp.ko

And also copy all those Digital Persona user level libraries to following location:

cp libdpfp* /usr/lib

5. I then run /sbin/depmod to let system detects the new kernel mode driver I have installed. This will refresh the /dev directory so it will have entries like:

/dev/usbdpfpPNP /dev/usbdpfp0

At this time, if all works right, when you run command lsmod, you will also see something like:

mod_usbdpfp

shows up in the loaded module list

6. At this time, you are ready to make a remaster of the Knoppix. Next time when you boot up with this remastered Knoppix, it will have the kernel driver and user level libraries setup ready for you to run the sample applications. Just as if you have done above step 2 and step 4 right after a refresh reboot from the original Knoppix CD.

John Xu, USA. ( johnxu at n2k.net )

Test CD Image Without Burning a CD

If you don't have an extra partition or you don't want to do so much for it, you can use Qemu ( see [1] ) with the ISO image like this:

qemu -m 128 -cdrom /temp/knoppix-custom.iso -boot d -net user

You even do not have to build a hard disk image before, just install Qemu and try this. Amazing!

Knoppix 6.2 Contains Sun's VirtualBox

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

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:

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

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 master/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).

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.

Tips around apt-get to install/update/remove applications

(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
# Assumes that the current directory is the working space
# original.iso is an image of the CD we will be using as master
mount -t iso9660 original.iso ./oldcd -o ro,loop
# initialize the compressed loop device
losetup /dev/cloop1 ./oldcd/KNOPPIX/KNOPPIX
mount -t iso9660 /dev/cloop1 ./KNOPPIX -o ro,loop
  • 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.
  • 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
# Clean package files generated by aptitude
rm /var/log/aptitude
rm /var/lib/apt/lists/*debian*
rm /var/lib/apt/lists/*knoppix*

Conclusion

Thats it. This is an updated version of previous howto. This is not meant for linux beginners.

Feel free to edit or add to this howto.

Translations

Revised Version