VizagInfo.com Home | VizagInfo Mirror of LG


[ Prev ][ Table of Contents ][ Front Page ][ Talkback ][ FAQ ][ Next ]
LINUX GAZETTE
...making Linux just a little more fun!
I Built a Custom Debian CD from Knoppix
By Sunil Thomas Thonikuzhiyil

Introduction

    Knoppix is a live cd distribution based on debian GNU/Linux.It contains a large number of applications which can come in handy even on minimal hardware.Knoppix supports alarge number of graphics cards sound cards scsi and USB devices.It can be used as a Linux demo, educational cd, rescue system or adapted and used as a platform for commercial product demo. It is not necesary to install anything to hard disk There is an installation program which can install the entire cd to a hard disk, if you like. It means that you have a full fledged debian installation in 20 minutes. This document describes how I built a custom live cd from knoppix. My primary motivation to build this cd was to include some of my favorite applications which are missing from stock knoppix CD.  If you find any errors in this document please drop me a mail here

Requirements

a) Software

To start with you have to download knoppix image from knoppix site. There is a release every one  or two week. There are 2 images: German and English. I did my setup based on 31-10-2002-EN release.

  If you already have an image you can try to rsync it to the most recent version as below. However don't expect much bandwidth saving since the knoppix image is compressed. If you have a knoppix cdrom create an image by   #dd if=/dev/cdrom of=knoppix.iso)

Rename the Knoppix iso image to reflect the current release name.
  Example
  I have downloaded KNOPPIX_V3.1-23-10-2002-EN.iso
  I want to update it to   KNOPPIX_V3.1-31-10-2002-EN.iso
  Rename KNOPPIX_V3.1-23-10-2002-EN.iso to  KNOPPIX_V3.1-31-10-2002-EN.iso
 Then
 rsync -P --stats ftp.leo.org::Knoppix/KNOPPIX_V3.1-31-10-2002-EN.iso  .
( you can use any other rsync site of knoppix. Always check the site for latest release)

b) Hardware

A Computer with tons of free hard disk space and memory. I did this on a Pentium 3 950MHZ machine with 128 mb RAM.


Initial setup

 Make a lot of  disk space free  You need a lot of real estate for re-mastering KNOPPIX  CD
   I made two fresh partitions  on my 20 GB Hard disk
           hda2 with 2GB  for swap
           hda3 with 5 GB for re-mastering work ( you can also  use an existing Linux partition if it has sufficient  free space)

 Now boot the machine with Knoppix cd ( You can also do the re-mastering after a  hard disk install of knoppix . A how to for hard disk install  can be found here )

   At boot prompt press enter. Knoppix now boots into GUI. The default is KDE . You  can change it at boot prompt if you want . I did re-mastering  while booted to KDE. It is assumed that you are somewhat familiar with Knoppix.  Read  Knoppix cheat codes on the CD  for more information on booting.

a) Configure networking from the KDE menu

  Click on
K/Knoppix/network-Internet/Network-card-configuration

    I am connected to a Lan and I configured IP address, netmask, name server and gateway This step is very important since you have to get the custom stuff to be installed from else where

b) Setup partitions

Open a root shell from KDE menu  (K/Knoppix/Root-shell)  You will get  # prompt

Run cfdisk

Next you have to make the necessary  partitions . I  created two partitions hda2 with 2 GB and  hda3 with 5 GB

Make the 2GB  partitions type as swap  ( /hda2 in my case)

Make the 5 GB partitions type as Linux native( ext2)  (hda3 here)
Save the modified partition information

Quit cfdisk

 For creating compressed file system we need a lot of swap space . I created the swap with
 # mkswap /dev/hda2
 # swapon /dev/hda2               

( it is also possible to use a swap file )

Create an ext2 file system on the 5GB partition
  # mke2fs /dev/hda3

Mount the 5GB  partition to the Knoppix file system
# mount /dev/hda3 /mnt/hda3

The basic setup for re-mastering is ready


Installing and Removing Software

The knoppix CD  is organized somewhat like the figure below ( Correct me if I am wrong. it may  look different when you look at it from windows or another Linux distro)

     
/--demos
|--talks
|--index.html
|--autorun.bat
|--autorun.inf
|--knoppix.ico
|--KNOPPIX
      |--KNOPPIX
      |--boot.img
      |--background.gif
      |- (Some more files here)

 The file KNOPPIX in  /KNOPPIX  directory on the cd is approxiamtley 700MB. The file contains a compressed image of the file system. We have to modify this file alone and can leave the rest of  the cd intact (unless you want to modify boot image startup files etc).

a) Copy Knoppix file system to hard disk

When Knoppix CD is booted compressed image file is mounted at /KNOPPIX You have to copy it to your target partition.I did a
# cp -Rp  /KNOPPIX    /mnt/hda3/ 
( -R option is for recursive copying -p is for preserving ownership time stamp etc) This places all the files you need to make a custom cd on your hard disk  at /mnt/hda3/KNOPPIX/ directory . Take a look at it

b) Chroot

 You have to install/uninstall software under this tree ( if you don't have networking copy your sources to  (say)  /mnt/hda3/KNOPPIX/root/  and if you have debs copy them to  /mnt/hda3/KNOPPIX/var/cache/apt/archives)
Now we are going to change the root of the file system to /mn/hda3/KNOPPIX
#chroot /mnt/hda3/KNOPPIX

you will get back # prompt ( If you get /dev/null  permission denied message here just press control C)
 You  are at   / ( chrooted to /mnt/hda3/KNOPPIX)

Next mount the proc file system
#mount -t proc /proc proc    

c) Setup networking

Add to  /etc/resolv.conf
nameserver ip-of-ur-nameserver

 ( I had a curious problem /etc/resolv.conf was a symlink to /etc/dhcp/resolv.conf. Ping did not work. I removed the symlink and created a /etc/resolv.conf afresh and it worked. Make sure that you restore the symlink  once you are finished)

Verify your ip address now with ifconfig. (It should be same as what you have out side chroot) Then try  ping google.com. If you  can ping google.com your network setup  is ok under chroot.Do an apt get update 

d) Install/Uninstall

You can install /uninstall whatever software you  need using apt. Since the original Cd has a lot of software installed it may not be an easy task.The following is a partial list of packages I removed

 Games

falconseye-data
rocks-n-diamonds
amor
nethack-x11
gnome-games-locale
xboard
gnocatan-client
imaze
kmahjongg
gnome-gnibbles
freeciv-gtk
ktuberling
gnocatan-help
ksirtet
gnome-gnobots2
jumpnbump
ksnake
xgalaga
lskat
katomic
kshisen
konquest
chromium
ktux
moon-buggy
kmoon
ksame
gnuchess
ktron
frozen-bubblekjumpingcube
fortune-mod
kodo
gnocatan-ai
gnocatan-server-console
gnocatan-server-data
nethack
821
fortunes
searchandrescue
xbill
kspaceduel
libkdegames
tipptrainer-data-dexconq
gcompris
gnome-chess
tuxracer-data
abuse-frabs
gnome-gnotski
frotz
kblackbox
gnome-games
gnome-gtali
gnome-iagno
gnome-stones
gnocatan-server-gtk
lxdoom-x11
maelstrom
kabalone
gnome-gnotravex
fortunes-min
chromium-data
kdegames
pingus-data
task-kde-games
stax
gnome-card-games
xtris
xtux
kjezz
lxdoom

Non -free

x3270
xanim festlex-oald
netscape-java-477
j2re1.3
3270-common
tgif
giflib-bin
frotz xfractint
giflib3g communicator-smotif-477
netscape-base-477
maelstrom communicator-base-477
gimp1.2-nonfree
acroread
lha
unarj
xsnow

Misc  

tetex-base
tetex-extra
j2re1.3  
lyx
acroread
qcad
rocks-n-diamonds 
kde-i18n-da
kde-i18n-it
kde-i18n-de
kde-i18n-fr
kde-i18n-ru
kde-i18n-nl
kde-i18n-ja
kde-i18n-es 
kde-i18n-cs
kde-i18n-pl
kde-i18n-tr
xfonts-intl-chinese
kword
kpresenter
abiword-gtk
karbon
kchart
kformula
kivio
koffice-libs
kontour
koshell
kspread

 I copied the above list to a file ( say kicklist)  then did
    #dpkg -P `cat kicklist`  
It removed all files listed (notice the back quote above )

If you are looking for big installed packages
      #  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.

Finally run deborphan to check if there are any orphaned packages
#deborphan > /tmp/orphanlist
#dpkg -P `cat /tmp/orphanlist`
# rm /tmp/orphanlist 

An alternate method is to use  synaptic and add/remove packages from GUI. Synaptic is good graphical front end to apt

For this do
# apt-get install synaptic
You have to export DISPLAY environment variable for synaptic to work properly
#DISPLAY=myip:0.0    ( replace my ip with your actual IP)
#export DISPLAY
#synaptic

It will start synaptic
Enjoy apt through synaptic

Once you are finished with synaptic you can re master the cd. If you are  working from a hard disk install of knoppix  and want synaptic to work, look in/etc/X11/xinit/xserverrc  and see that -nolisten tcp is removed.Also do xhost + as a non root user)

Unmount proc  ( This is very important)
 #umount /proc

Press control D to leave chrooted environment

Further Customization  

1  Installing applications compiled from source  

 Download the software source inside chroot environment. Compile and install as usual . If it is an X11 application export display before you test
I use checkininstall asic-linux.com.mx/~izto/checkinstall/ to install and maintain home brew debs
Remember to remove the sources once you are finished (it will take up space on your CD).

2)  Changing user settings    

It is possible to set password for users. Just set it under chrooted environment

3) Changing backgrounds

/usr/local/lib/knoppix.gif is the default background image in X

4) Modifying Boot Screen  

 The Knoppix Cd uses syslinux to boot. If you want to change the boot screen/messages do the following. Make a temporary directory on your hard disk (I did mkdir /mnt/hda3/image)
 Copy the boot.img  file from  Knoppix  directory of your knoppix cd 
       #cp /KNOPPIX/boot.img /mnt/hda3
 Mount the image as follows
      # mount -t msdos -o loop   /mnt/hda3/boot.img  /mnt/hda3/image
  Now look in the image directory you created. There are a number of interesting  files in this directory

    a) Boot logo
logo.16 is the image displayed on boot screen.  It is encoded in a special format. For replacing it grab a 640*400  16 color image. I downloaded an image from gnu.org. Convert the image to a png file ( call it logo.png) 
 
       #pngtopnm <logo.png >logo.pnm
      #ppmtolss16 <logo.pnm >logo.16
    # cp logo.16 /mnt/hda3/image/logo.16

  (Keep the size of the final log.16 around 50 k). Unmount image directory. Copy the boot.img to a floppy
   #dd if=boot.img of=/dev/fd0
Boot the machine from the floppy you have made. If it boots up properly you are done

 b)  syslinux.cfg
  By modifying syslinux.cfg you can change a number of parameters passwd on to the kernel. Read the man pages of syslinux for more details
  5)Modifying  kernel  ( ****Untested  ****)         

Make a  new custom kernel using kernel package . Keep the kernal size small. Copy the kernal to and modules to boot.img file. replace /lib/modules/2.4.19-xfs  with  modules of your new kernel
   Replace files in  /boot  

6)Changing default GUI to Gnome/ icewm
 Changing default gui to something else is quite easy
  Under the chrooted environment  open the file
     /etc/init.d/knoppix-autoconfig

  Look for the following lines
---------------------------------------

#Also read desired desktop, if any

DESKTOP="$(getbootparam desktop 2>/dev/null)"

# Allow only supported windowmanagers

case "$DESKTOP" in gnome|kde|larswm|xfce|windowmaker|wmaker|icewm|fluxbox|twm) ;; *)

  DESKTOP="KDE"; ;; esac
--------      ^^   --------------------------------------

  Change the KDE above to gnome and that is all 

 7)  Remove any temporary files 
    a)   Look in /root  for hidden files such as .bash_history .viminfo
    b)   Nuke all deb files in  /var/cache/apt/archives 
     c)  Run the knoppix.clean script   ( Be careful and run it only from  chrooted environmant)

 (* link to the script goes here*)       

Re mastering the CD

a)Make an ISO image

 1)  Make a new directory on /mnt/hda3
   I called it NewCd
    Copy Everything except Compressed image file(KNOPPIX) from knoppix cd (look at /cdrom). You can safely delete the directories demos and  talks
  2) Create the compressed Image
   #mkisofs -R   /mnt/hda3/KNOPPIX  |  create_compressed_fs -   65536  > /mnt/hda3/NewCD/KNOPPIX/KNOPPIX   

 3) Recreate the bootable CD
 #cd /mnt/hda3

 #mkisofs -r -J -b KNOPPIX/boot.img -c KNOPPIX/boot.cat   -o myknoppix.iso  NewCd

b)Testing the image

Create a boot floppy
# dd if=/mnt/hda3/KNOPPIX/boot.img of=/dev/fd0 
Copy the compressed file you created to a directory /KNOPPIX on any partition. The boot floppy i will look for /KNOPPIX/KNOPPIX on hard disk partitions.This makes your testing easy. Once you are satisfied with your image burn itto a CD  

FAQ

 1) How do I  stop konquerer at startup
  To stop konquerers you  have to modify
        /etc/X11/Xsession.d/45xsession
    Look for the following lines

-------------------------------------------
if [ -e "$INDEXFILE" ]; then
cat >> $HOME/Desktop/KNOPPIX.desktop <<EOF
[Desktop Entry]
Name=KNOPPIX
Exec=kfmclient openProfile webbrowsing $INDEXFILE
Type=Application
Icon=html
Terminal=0
EOF
ln $HOME/Desktop/KNOPPIX.desktop $HOME/.kde/Autostart/showindex.desktop
fi

----------------------------------------- 

 It makes an autostart file. Comment it  out

2) I have booted knoppix cd and mounted a hard disk how do i copy something via scp to the hard disk
      Open a  shell
      set a password for user knoppix
      start ssh  (/etc/init.d/ssh start)
      Then copy with scp

 3 I am at $ prompt I want to su
      Do  sudo  passwd
      set a  root password
      then su

 4) default text mode boots up in frame buffer and characters are very small how do I fix it
     Mount boot.img
     look for syslinux.cfg
     under  Default  vmlinuz
     change VGA=791 to VGA=normal

5 )My keyboard lay out is  German.  How do i change it to English
 Open KDE control center select system ->keyboard and change it to US English

References

      I have adapted lot of material from the following links. Also #knoppix on irc.freenode.net is a good source of information
1)Tech2k home page
Ken Burk helped me a lot on irc to improve this document . His site has excellent information which you can always rely on. His kix remastering page is also very good
2) Knoppix.net
  The unofficial knoppix site is a great  source  of information. Lots of new stuff regarding re-mastering appear there regularly
3) Knoppix forum at linuxtag
This site mixture of German and English . Very good source on Knoppix

 

[BIO] I work as consultant information technology at the Kerala Legislative Assembly Trivandrum India. I have been hooked on Linux since 1996. I have a Masters in Computer Science from Cochin University. I am interested in all sorts of operating systems. In my free time I love to listen to Indian classical music.


Copyright © 2003, Sunil Thomas Thonikuzhiyil. Copying license http://www.linuxgazette.com/copying.html
Published in Issue 87 of Linux Gazette, February 2003

[ Prev ][ Table of Contents ][ Front Page ][ Talkback ][ FAQ ][ Next ]