Difference between revisions of "Knoppix Remastering with Menu Based Scripts"


From Knoppix Documentation Wiki
Jump to: navigation, search
Line 210: Line 210:
 
So far, all of the tasks I have done have been on the command line and requires quite a bit of knowledge and some people view the command line as tedious work. Fortunately you can also use synaptic to add/remove packages. Before entering a graphical enviornment, you need to make sure it is configured.  
 
So far, all of the tasks I have done have been on the command line and requires quite a bit of knowledge and some people view the command line as tedious work. Fortunately you can also use synaptic to add/remove packages. Before entering a graphical enviornment, you need to make sure it is configured.  
  
'''This next command must be done outside the chroot'''. From virtual terminal 2 <ALT-F2>, copy the XF86Config-4 file from /etc/X11 to /mnt/hda2/etc/X11 (This file won't exist if you booted to runlevel two, so either grab it from a graphically booted Knoppix, or hopefully you have one that works for the system you are working from:
+
Copy /etc/skel to /home/knoppix
  
  cp /etc/X11/XF86Config-4 /mnt/hda2/remaster/etc/X11
+
  cp -Rp /etc/skel /home/knoppix
  
I am done with commands outside the chroot and the rest of the commands need to be done inside the chroot. Flip back to virtual terminal 1 <ALT-F1> and copy /etc/skel to /home/knoppix
 
cp -Rp /etc/skel /home/knoppix
 
 
Change the user of /home/knoppix & its files to user knoppix
 
Change the user of /home/knoppix & its files to user knoppix
chown -R knoppix:knoppix /home/knoppix
 
= END OF FIRST HALF =
 
If you performed the first half of this HOWTO from within KDE, then you must follow these steps. If you performed the first half of the HOWTO from console command line session, then DO NOT DO THESE STEPS! You can skip down to the start of the last half. Exit the chroot by typing exit or <CTRL-D>. Exit the menu by choosing option 6 "Quit the program." Use the following command to go to runlevel 2.
 
init 2
 
It will close KDE and leave you at a command prompt.
 
cd /mnt/hda2/scripts
 
./knoppix-remaster /mnt/hda2/remaster
 
Choose "No", I do not want to create a new remaster. Hit <ENTER> to choose the path /mnt/hda2/remaster as default. Choose the chroot option to enter the chroot. This section is complete.
 
= START OF LAST HALF =
 
Begin For Knoppix 3.8.1 Only
 
Now inside the chroot as root user, change the permissions of /tmp to full read/write and execute. If you do not, then KDE will not run.
 
chmod 777 /tmp
 
End For Knoppix 3.8.1 Only
 
  
Become the user knoppix
+
chown -R knoppix:knoppix /home/knoppix
su - knoppix
+
 
 +
'''This next command must be done outside the chroot'''. From virtual terminal 2 <ALT-F2> or another konsole session, copy the XF86Config-4 file from /etc/X11 to /mnt/hda2/etc/X11 (This file won't exist if you booted to runlevel two, so either grab it from a graphically booted Knoppix, or hopefully you have one that works for the system you are working from:
 +
 
 +
cp /etc/X11/XF86Config-4 /mnt/hda2/remaster/etc/X11
 +
 
 +
==== If currently in KDE environment ====
 +
 
 +
If you performed the first half of this HOWTO from within KDE, then you must follow these steps. If you performed the first half of the HOWTO from console command line session, then DO NOT DO THESE STEPS! 
 +
 
 +
Exit the chroot by typing exit or <CTRL-D>. Exit the menu by choosing option 6 "Quit the program." Use the following command to go to runlevel 2.
 +
 
 +
init 2
 +
 
 +
It will close KDE and leave you at a command prompt.  (It may appear hung, but press Enter and you should see the command prompt.
 +
 
 +
cd /mnt/hda2/scripts
 +
./knoppix-remaster /mnt/hda2/remaster
 +
 
 +
#Choose "No", I do not want to create a new remaster.
 +
#Hit <ENTER> to choose the path /mnt/hda2/remaster as default.
 +
#Choose the chroot option to enter the chroot. This section is complete.
 +
 
 +
=== Finally start graphical environment ===
 +
 
 +
NOTE for noppix 3.8.1 and higher:
 +
You may need to change the permissions of /tmp to full read/write and execute. If you do not, then KDE might not run.
 +
 
 +
chmod 777 /tmp
 +
 
 +
END NOTE
 +
 
 +
Become the user knoppix and startx
 +
 
 +
su - knoppix
 +
 
 +
(If you get a /dev/null permissions problem do
 +
 
 +
chmod 666 /dev/null
 +
exit
 +
su - knoppix
 +
 
 +
)
 +
 
 
Start X which will start KDE and bring us to a graphical desktop
 
Start X which will start KDE and bring us to a graphical desktop
startx
+
 
Now that it is in KDE, I can change the fonts to Bitstream Vera Sans and enable anti-aliasing. I can disable the menu translucency and the konsole translucency. I can use synaptic to add mozilla firefox, openoffice.org, vncviewer, kdeartwork which contains the Plastik widget style, and I can even update KDE from 3.2.3 to 3.3. If I do update all or parts of KDE, it is suggested that I exit KDE (close session), drop back to the command prompt and rerun startx to make sure it is applied. When I am happy with all the changes that I have made, then it is time to exit KDE. I exit KDE (close session) and I am dropped back at the prompt. I type exit to exit my session as the user knoppix and I am now root.
+
startx
= THIS IS COMPLETELY OPTIONAL =
+
 
This assumes that you have at least 3GB of additional free hard disk space. At this point I want to make a safe backup copy of all the changes that I have made. If you do not want to make a backup copy then skip this part. I exit the chroot by either typing exit or using the keyboard <CTRL-D>. Now back at the menu, I choose option 6, and quit the program. Next I mount hdb1
+
Now that it is in the GUI, you can change the fonts, disable the menu translucency and the konsole translucency.  
mount -t ext3 /dev/hdb1 /mnt/hdb1
+
 
Now I copy the whole remaster to hdb1 for safe keeping.
+
You can use synaptic to add packages like mozilla firefox, openoffice.org, vncviewer, kdeartwork which contains the Plastik widget style, and you can even update the window manager. If you do update all or parts of KDE, it is suggested that I exit KDE (close session), drop back to the command prompt and rerun startx to make sure it is applied.  
cp -Rp /mnt/hda2/remaster /mnt/hdb1/backup-remaster
+
 
With that complete, I unmount hdb1.
+
When you are happy with all the changes that you have made, then it is time to exit .  
umount /mnt/hdb1
+
 
When that is complete I rerun the knoppix-remaster command and tell it "No", I do not want to create a new remaster. Hit <ENTER> to choose the path /mnt/hda2/remaster as default.
+
#Exit (close session) and I am dropped back at the prompt.  
./knoppix-remaster /mnt/hda2/remaster
+
#Type exit to exit my session as the user knoppix and you are now root.
 +
 
 +
== Other customizations ==
 +
=== To keep certain desktop settings persistent ===
 +
 
 +
I must now mention the file /etc/X11/Xsession.d/45xsession. This script controls how knoppix behaves & how knoppix creates the knoppix user's home directory.
 +
 
 +
Edit the file /etc/X11/Xsession.d/45xsession and look for the ninth occurence of rsync in the script and it is found at or around line 128:
 +
 
 +
126: if [ -z "$DONTCHANGE" ]; then
 +
127: # No persistent homedir, copy everything
 +
128: rsync -Ha --ignore-existing /etc/skel/{.kde*,Desktop} $HOME/ 2>/dev/null
 +
129: [ "$USER" = "knoppix" ] && rsync -Ha --ignore-existing /usr/share/knoppix/profile/{.kde*,Desktop} $HOME/ 2>/dev/null
 +
 
 +
 
 +
It is line 128 which populates the /home/knoppix folder. So In line 128, I delete from & including the { to the }. It is changed as follows.
 +
 
 +
126: if [ -z "$DONTCHANGE" ]; then
 +
127: # No persistent homedir, copy everything
 +
128: rsync -Ha --ignore-existing /etc/skel/ $HOME/ 2>/dev/null
 +
129: [ "$USER" = "knoppix" ] && rsync -Ha --ignore-existing /usr/share/knoppix/profile/{.kde*,Desktop} $HOME/ 2>/dev/null
 +
 
 +
Make the change and save the 45xsession file.
 +
 
 +
= Backing up chroot environment =
 +
 
 +
This assumes that you have at least 3GB of additional free hard disk space. At this point you may want to make a safe backup copy of all the changes that you have made. If you do not want to make a backup copy then skip this part.  
 +
 
 +
#Exit the chroot by either typing exit or using the keyboard <CTRL-D>.  
 +
#Now back at the menu, choose option 6, and quit the program.  
 +
#Next you may need to mount the drive that you have space on for backups, in our example: hdb1
 +
 
 +
mount -t ext3 /dev/hdb1 /mnt/hdb1
 +
 
 +
Now copy the whole remaster to hdb1 (or some other place) for safe keeping:
 +
 
 +
cp -Rp /mnt/hda2/remaster /mnt/hdb1/backup-remaster
 +
 
 +
#When that is complete I rerun the knoppix-remaster command and tell it "No", I do not want to create a new remaster.  
 +
#Hit <ENTER> to choose the path /mnt/hda2/remaster as default.
 +
 
 +
./knoppix-remaster /mnt/hda2/remaster
 +
 
 
I choose option 1 and chroot into the remaster.
 
I choose option 1 and chroot into the remaster.
= END OF COMPLETELY OPTIONAL =
+
 
NOTE: The rest of the steps are written with the assumption that it is being done from runlevel 2. However they can be done within KDE by typing init 5, running the knoppix-remaster script, and then chroot into the remaster. Now I need to make the changes to the system so that the knoppix CD will boot without errors. As a reminder, these commands need to be done inside the chroot, virtual terminal 1 <ALT-F1>. Delete the existing /etc/skel.
+
= Final manual cleanup steps =
rm -rf /etc/skel
+
 
 +
NOTE:  
 +
The rest of the steps are written with the assumption that it is being done from runlevel 2. However they can be done within KDE by typing init 5, running the knoppix-remaster script, and then chroot into the remaster.  
 +
 
 +
Now you need to make the changes to the system so that the knoppix CD will boot without errors. As a reminder, these commands need to be done inside the chroot, virtual terminal 1 <ALT-F1>.  
 +
 
 +
Delete the existing /etc/skel.
 +
 
 +
rm -rf /etc/skel
 +
 
 
Move /home/knoppix to /etc.
 
Move /home/knoppix to /etc.
mv /home/knoppix /etc/skel
+
 
 +
mv /home/knoppix /etc/skel
 +
 
 
Change the owner back to root.
 
Change the owner back to root.
chown -R root:root /etc/skel
+
 
 +
chown -R root:root /etc/skel
 +
 
 
Remove the XF86Config-4 file as it will get recreated on every bootup.
 
Remove the XF86Config-4 file as it will get recreated on every bootup.
rm /etc/X11/XF86Config-4
 
  
Begin For Knoppix 3.8.1 Only
+
rm /etc/X11/XF86Config-4
Now inside the chroot as root user, change the permissions of /tmp back to full read and execute.
+
 
chmod 555 /tmp
+
If you had to change the permissions for /tmp then change them back:
End For Knoppix 3.8.1 Only
+
 
 +
chmod 555 /tmp
 +
 
 +
Enter the following command to clean up the downloaded .deb packages.
 +
 
 +
apt-get clean
  
I must now mention the file /etc/X11/Xsession.d/45xsession. This script controls how knoppix behaves & how knoppix creates the knoppix user's home directory. I am looking for the ninth occurence of rsync in the script and it is found at the line 128:
 
126: if [ -z "$DONTCHANGE" ]; then
 
127: # No persistent homedir, copy everything
 
128: rsync -Ha --ignore-existing /etc/skel/{.kde*,Desktop} $HOME/ 2>/dev/null
 
129: [ "$USER" = "knoppix" ] && rsync -Ha --ignore-existing /usr/share/knoppix/profile/{.kde*,Desktop} $HOME/ 2>/dev/null
 
It is line 128 which populates the /home/knoppix folder. So In line 128, I delete from & including the { to the }. It is changed as follows.
 
126: if [ -z "$DONTCHANGE" ]; then
 
127: # No persistent homedir, copy everything
 
128: rsync -Ha --ignore-existing /etc/skel/ $HOME/ 2>/dev/null
 
129: [ "$USER" = "knoppix" ] && rsync -Ha --ignore-existing /usr/share/knoppix/profile/{.kde*,Desktop} $HOME/ 2>/dev/null
 
Make the change and save the 45xsession file. Enter the following command to clean up the downloaded .deb packages.
 
apt-get clean
 
 
I want to remove any traces of recently used programs in KDE so I edit /etc/skel/.kde/share/config/kickerrc and I find the field that reads something like
 
I want to remove any traces of recently used programs in KDE so I edit /etc/skel/.kde/share/config/kickerrc and I find the field that reads something like
RecentAppsStat=9 1096000374 /usr/share/applications/mozilla.desktop
+
 
 +
RecentAppsStat=9 1096000374 /usr/share/applications/mozilla.desktop
 +
 
 
I edit the line and leave the end blank
 
I edit the line and leave the end blank
RecentAppsStat=
+
 
I am now all done with the customization and want to exit the chroot by either typing exit or using the keyboard <CTRL-D>. I flip back to virtual terminal 2 <ALT-F2>, and since I am paranoid, I delete /mnt/hda2/remaster/etc/skel/.bash_history & delete /mnt/hda2/remaster/root/.bash_history.
+
RecentAppsStat=
rm /mnt/hda2/remaster/etc/skel/.bash_history /mnt/hda2/remaster/root/.bash_history
+
 
I flip back to virtual terminal 1 <ALT-F1> and run the knoppix-remaster script.
+
#Exit the chroot by either typing exit or using the keyboard <CTRL-D> and fliping back to virtual terminal 2 <ALT-F2>
./knoppix-remaster /mnt/hda2/remaster
+
 
I choose option 2 "Create compressed fs". It will ask me "Do you want to cleanup your remaster?" & I choose yes.
+
If you are paranoid delete /mnt/hda2/remaster/etc/skel/.bash_history & delete /mnt/hda2/remaster/root/.bash_history.
NOTE: a remaster filesystem of about 2.1GB compresses down to about 685MB CD ISO. I can check the system size by issuing the commands df -h or du -h --max-depth=1.
+
 
 +
rm /mnt/hda2/remaster/etc/skel/.bash_history /mnt/hda2/remaster/root/.bash_history
 +
 
 +
= Create the compressed filesystem =
 +
 
 +
Flip back to virtual terminal 1 <ALT-F1> and run the knoppix-remaster script.
 +
 
 +
./knoppix-remaster /mnt/hda2/remaster
 +
 
 +
I choose option 2 "Create compressed fs".  
 +
 
 +
It will ask me "Do you want to cleanup your remaster?" & I choose yes.
 +
 
 +
NOTE:  
 +
a remaster filesystem of about 2.1GB compresses down to about 685MB CD ISO. You can check the system size by issuing the commands df -h or du -h --max-depth=1.
  
 
At this point it is fully automated and will create compressed Knoppix filesystem that is found on the Knoppix CD.
 
At this point it is fully automated and will create compressed Knoppix filesystem that is found on the Knoppix CD.
  
Compression times that I have experienced
+
Example compression times:
  
 
* Pentium 3 - 450 MHz 384MB aprox. 1hr 15min
 
* Pentium 3 - 450 MHz 384MB aprox. 1hr 15min
Line 292: Line 382:
 
* Opteron 242 (1.4GHz) 1GB RAM aprox 12 min
 
* Opteron 242 (1.4GHz) 1GB RAM aprox 12 min
  
When the compressed filesystem step is complete, I choose option 3 "Create isofs" to create the ISO file. Again, through the wonders of these scripts, it is all automated. Once that step is complete, I choose the option 6 & quite the program.
+
= Create ISO image =
I finished ISO file is located at /mnt/hda2/remaster/Knoppix.build/Knoppix.Master/KNOPPIX-CUSTOM.iso.
+
 
At this point I burn the ISO to CD. If you have an available CDRW drive in your system like my /dev/hdd, then type init 5 to go to runlevel 5 where it runs KDE and you can burn the CD with K3B. Or you can burn the CD from the command line. First get the CDRW device ID numbers via
+
When the compressed filesystem step is complete, choose option 3 "Create isofs" to create the ISO file. Again, through the wonders of these scripts, it is all automated. Once that step is complete, choose the option 6 & quite the program.
cdrecord -scanbus
+
 
It will scan your system and display a list of devices. Identify the ID numbers in form #,#,#. My CDRW is 1,1,0. Load the CDRW drive with a blank CDR and use the command below to burn the ISO to the CDR.
+
The finished ISO file, for this example, is located at /mnt/hda2/remaster/Knoppix.build/Knoppix.Master/KNOPPIX-CUSTOM.iso.
cdrecord -v gracetime=2 dev=1,1,0 speed=32 -dao driveropts=burnfree -eject -data /mnt/hda2/remaster/Knoppix.build/Knoppix.Master/KNOPPIX-CUSTOM.iso
+
 
If you do not have a available CDRW drive, then perhaps you can boot into the graphical KDE environment via init 5. In KDE you can use the Knoppix menu and start the samba service to permit sharing of the hard drives via Windows network filesharing. Or you can copy the ISO to a FAT32 partition.
+
= Burn ISO image =
 +
 
 +
At this point burn the ISO to CD. If you have an available CDRW drive in your system like /dev/hdd, then type init 5 to go to runlevel 5 where it runs KDE and you can burn the CD with K3B. Or you can burn the CD from the command line. First get the CDRW device ID numbers via
 +
 
 +
cdrecord -scanbus
 +
 
 +
It will scan your system and display a list of devices. Identify the ID numbers in form #,#,#. This example will use 1,1,0. Load the CDRW drive with a blank CDR and use the command below to burn the ISO to the CDR.
 +
 
 +
cdrecord -v gracetime=2 dev=1,1,0 speed=32 -dao driveropts=burnfree -eject -data /mnt/hda2/remaster/Knoppix.build/Knoppix.Master/KNOPPIX-CUSTOM.iso
 +
 
 +
If you do not have a available CDRW drive, then perhaps you can boot into the graphical KDE environment via init 5. In KDE you can use the Knoppix menu and start the samba service to permit sharing of the hard drives via Windows network filesharing. Or you can copy the ISO to a FAT32 partition.  Or scp it somewhere, etc.
  
 
[[Category: Remastering Knoppix ]]
 
[[Category: Remastering Knoppix ]]

Revision as of 21:35, 10 November 2005

Introduction

This is based on the document originally written by James Pryor at the http://knoppix.net forum pages and at http://www.virtualacuity.com/james/knoppix-howto.

This HOWTO can also be found on the Knoppix.net forums. HOWTO: Remaster KNOPPIX the easy way using menu based remaster scripts.

This HOWTO can also be found on the Knoppix.net forums. HOWTO: Remaster KNOPPIX the easy way using menu based remaster scripts.


Disclaimer

Use this at your own risk. I am not responsible for anything that might go wrong. I am human and I may have made a mistake in this HOWTO. Please private message me if you notice any typos or errors. Corrections & suggestions are welcome.

Why Remaster

Knoppix is the best Linux live CD available. However, you might have the desire to have your own custom Knoppix. The remastering process is a way creating a new Knoppix CD based off your customizations. Some obvious reasons for making a custom Knoppix CD: - Knoppix does not have the programs that you require. - Knoppix is too big to fit on a USB flash drive. - Knoppix does not support your language. - You wish to change the default KDE themes & settings. See the Knoppix Wish List for more ideas.

Why James wrote parts of this HOWTO

This HOWTO is compiled from my numerous attempts of remastering, the knoppix.net documentation, and the brilliant posters in the forums. At knoppix.net, the documentation is well done and thorough and the remastering/customization documentation references a detailed and involved method of remastering. I have used this method of remastering and it works. In August, two Knoppix developers, Klaus Knopper & Fabian Franz, created a new set of scripts that "wrap around" the older method with a menu system. This menu simplifies the remastering process and hides the long and sometimes confusing commands from the user. This is my attempt to bring to light this new method that uses these scripts.

From http://www.ukuug.org/events/linux2004/knoppix.shtml:

Remastering KNOPPIX has always been a lot of hassle -- requiring numerous intricate steps on the command line making it easy to forget an important step. While there are several HOWTOs on the net that explain the steps, Ian Naylor thought it would be a good idea to write some scripts to automate the process. He described this during this year's UKUUG Linux conference in Leeds, England. Ian presented a talk on "Building your own Live CD based on KNOPPIX". Fabian Franz, a member of the KNOPPIX team who attended the talk, said afterwards: Ian's scripts just opened my eyes -- it was a very clear structure and for the first time in my life I understood the remastering process from a user's point of view.
Ian and Fabian started talking after the presentation and were inspired to develop a new graphical remastering tool to build acustomised KNOPPIX distribution. One day later Fabian was demonstrating the new script to a stunned audience. Unlike previous efforts to solve the same problem this is based on Klaus Knopper's originalscripts and written in a way so that future improvements in themaster scripts will be reflected in these.

Credits

Thanks to Klaus Knopper, Ian Naylor, Fabian Franz, Debian developers, KDE developers, the knoppix.net forum moderators, the plethora of knowledgeable forum posters and certainly knoppix.net site admin eadz for creating knoppix.net

Getting started

Assumptions

This HOWTO assumes that the user has basic knowledge of the command line programs such as ls, mv, cp, df -h, mkdir, etc. You will probably need to use a command line text editor such as vim, emacs, joe, zile. If you remaster in KDE then you can use any of the graphical editors. You will also need a basic understanding of the Debian apt-get method of package management. At any point during the remastering process, you can make a backup of your progress. This allows you to fully experiment with your remaster and you can add or delete as you see fit without having to start all over. You can read about making a backup in a section I labeled as "THIS IS COMPLETELY OPTIONAL".

Requirements

The total remastering time is dependant on the time it takes to make all the changes, the HD drive speed and CPU speed. I estimate about 2.5 hours for a mid-range system that follows the package changes listed below.

The first half of the HOWTO can either be done from the command line runlevel 2 or inside X at runlevel 5. The only time you are forced to drop to a console session is running X from the chroot. If you choose to remaster from within KDE (runlevel 5), then when you must follow the steps listed at the section labeled "= END OF FIRST HALF =". The HOWTO as a whole can be done from command line runlevel 2 without having to jump into KDE & runlevel 5. I use runlevel 5 because I like synaptic over aptitiude/apt-get and I hate the default Knoppix transparent menus and the Keramik widget style.

I learned how to remaster just to install the kdeartwork package just so I can get the plastik widgets (which will be default style for KDE 3.4 thank god). If you don't need to custom configure the knoppix user's KDE desktop, and if you are comfortable with the command line and aptitude/apt-get, then you can stay in runlevel 2 and complete the remastering process.

This HOWTO has been tested with versions:

  • Knoppix 3.6
  • Knoopix 3.7 Pro (German PC Welt)
  • Knoppix 3.7 public 2004-12-08
  • Knoppix 3.8.1 2005-04-08
  • Knoppix 3.8.2 Leah 19:43, 10 Nov 2005 (GMT)

You will need a PC that can boot Knoppix 3.6 or 3.7 to a graphical KDE desktop. You should be able to remaster on that PC as long as you have at least 1 GB combined swap & RAM and 3GB of hard drive space. The 3GB figure is calculated using a remaster filesystem of about 2.1GB which compresses down to about 685MB CD ISO.

NOTE

You do not need to format your C: drive or lose data. This system is my test & experiment system. I format/partition/reinstall Linux & windows on that system regularly. This means I completely lose whatever was on the hard drives.

Begin Remastering

Starting a development system

Knoppix 3.6

I boot to the console command line (called runlevel 2) with Knoppix 3.6 english using cheatcodes. knoppix 2 vga=normal

Knoppix 3.7

Get to the console command line (called runlevel 2) with Knoppix 3.7 using cheatcodes. knoppix 2 lang=us vga=normal

Knoppix Later versions

In most cases no special boot parameters are needed. The remastering process can be started from within KDE, and in fact, for configuring X later, it is useful to start from KDE.

Example build system partition setup

In this document all examples are based on a setup using:

  • /dev/hda1 swap partition of 1GB in size
  • /dev/hda2 partition of at least 6GB
  • /dev/hdb1 partition of lots of size (optional, this is used in this example as a backup location for remastering filesystems)

You can use a commands like

cfdisk /dev/hd<a/b>

or

fdisk /dev/hd<a/b>

To run partitioning tools at this point to create these partitions, and then a reboot would be recommended.

init 6

Again I boot with the appropriate cheatcodes/parameters. At the command prompt I format the filesystems.

mkswap /dev/hda1
swapon /dev/hda1
mke2fs -vj /dev/hda2
mke2fs -vj /dev/hdb1

Next I mount the hda2 partition which will be the place where I extract out the remaster

mount -t ext3 /dev/hda2 /mnt/hda2
mkdir /mnt/hda2/remaster
cd /mnt/hda2

Creating the chroot environment

Install the remastering scripts

Now get the remastering scripts located at http://debian.tu-bs.de/knoppix/remaster/, extract the scripts, and setup my directories:

wget http://debian.tu-bs.de/knoppix/remaster/remaster_0.1-6.tar.gz
tar zxvf remaster_0.1-6.tar.gz
mv remaster-0.1 scripts
cd scripts

Edit the config file so that my remastered CD is personalized. The config file is in the scripts folder at KNOPPIX.build/remaster_config.

Recommended
  • Leave the _FILESYSTEM variables alone.
  • Leave the REMASTER_COMPRESSION_BEST variable alone even though the best compression might be better since it would take about 4 to 6 times longer to make the compressed filesystem.

Proxy settings for remastering scripts

The cleanup remaster script uses apt-get and must access the Internet or the cleanup will fail. If you are behind a proxy and must authenticate against it to access the internet, then first gather the required proxy info and write it down in the following form:

http://username:passwd@yourproxy.company.com:portnumber/

You need to edit the knoppix-remaster script and add the proxy settings. At line 136, add new line for the proxy

136: cp -f /etc/dhcpc/resolv.conf "$REMASTER_CHOICE"/etc/dhcpc/
137: CREATE_COMPRESSED_FS="yes" CLEANUP="$REMASTER_CLEANUP" COMPRESSION_BEST="${REMASTER_COMPRESSION_BEST:+--best}" chroot $REMASTER_CHOICE" /KNOPPIX.build/Knoppix-3.4.mkcompressed "$REMASTER_MASTER" auto

Becomes

136: cp -f /etc/dhcpc/resolv.conf "$REMASTER_CHOICE"/etc/dhcpc/
137: export http_proxy="http://username:passwd@yourproxy.company.com:portnumber/"
138: CREATE_COMPRESSED_FS="yes" CLEANUP="$REMASTER_CLEANUP" COMPRESSION_BEST="${REMASTER_COMPRESSION_BEST:+--best}" chroot $REMASTER_CHOICE" /KNOPPIX.build/Knoppix-3.4.mkcompressed "$REMASTER_MASTER" auto

Use the remaster scripts to create the chroot environment

Run the remastering script with a command like (full path names seem to work best):

./knoppix-remaster /mnt/hda2/remaster

Then follow the menus and create a new remaster and hit <ENTER> for the default path. It will extract the contents of the CD.

When it is done it will ask if I want to chroot into the extracted enviornment. Choose the chroot option & it will drop you into a command line environment that is inside the extracted Knoppix filesystem.

To exit the chroot and get back to the menu, type exit or use the keyboard keys <CTRL-D>.

More information on the chroot environment

If you do not want to know more about the chroot, then skip this section. Chroot changes the perceived root ( / ) of the filesystem. Please examine the following command.

ls /etc/*.conf

That command when run outside a chroot will give us a listing of all .conf files in /etc which are physically on the Knoppix CD. However, that command run inside the chroot will give us a listing of all the .conf files in /etc which is really /mnt/hda2/etc. This means that in our case /mnt/hda2/remaster is mapped to /. Also, all commands run in a chroot only affect the chroot filesystem. See the following links for more info:

http://www.ketec.ie/WebHelp/oh_site_about_chroot.htm
http://www.ss64.com/bash/chroot.html
http://en.wikipedia.org/wiki/Chroot

Examples of ways to customize

(make sure to look at the Knoppix_Remastering_Howto for ideas and tips as well

The following command returns a listing of all packages installed.

dpkg-query -l | less

While that command is useful, you can use grep to sort out which packages you to remove. The following command shows me packages that kde uses for internationalization support and strips off all the other extraneous information.

dpkg-query -l | grep i18n | grep kde | cut -d' ' -f3

I can feed this to apt-get so that it will remove those packages.

apt-get remove `dpkg-query -l | grep i18n | grep kde | cut -d' ' -f3`

You could remove openoffice and other German tools as follows:

apt-get remove openoffice-de-en manpages-de trans-de-en

Remove enigma and bacula as follows:

apt-get remove enigma bacula-common

Remove emacs as follows:

apt-get remove emacs21 emacs21-bin-common emacs21-common emacsen-common gettext-el zile

This results in a reasonable base to begin updating and adding packages to this system. First configure /etc/apt/sources.list and add the appropriate entries for a local Debian mirror.

If you are behind a proxy and must authenticate against it to access the internet, then use the following command. export http_proxy="http://username:passwd@yourproxy.company.com:portnumber/"

After that is finished, add three useful packages:

apt-get install localepurge aptitude synaptic

Localepurge will only keep the locales that are marked. This means that it will free up additional space. After running through the configuration removing locales you don't need, you must run it from the command line:

localepurge

Aptitude is a console menu front end to apt and dpkg, while synaptic is a graphical front end to apt & dpkg.

Finally, update the system's package listing with the command:

apt-get -y update

Starting graphical environment from the chroot system

NOTE

There are ways to use GUI apps that don't require direct console access to the system, this is just nice to know how to do when using a dedicated development system. Check out the main Knoppix Remastering documentation, for more information on this.

So far, all of the tasks I have done have been on the command line and requires quite a bit of knowledge and some people view the command line as tedious work. Fortunately you can also use synaptic to add/remove packages. Before entering a graphical enviornment, you need to make sure it is configured.

Copy /etc/skel to /home/knoppix

cp -Rp /etc/skel /home/knoppix

Change the user of /home/knoppix & its files to user knoppix

chown -R knoppix:knoppix /home/knoppix

This next command must be done outside the chroot. From virtual terminal 2 <ALT-F2> or another konsole session, copy the XF86Config-4 file from /etc/X11 to /mnt/hda2/etc/X11 (This file won't exist if you booted to runlevel two, so either grab it from a graphically booted Knoppix, or hopefully you have one that works for the system you are working from:

cp /etc/X11/XF86Config-4 /mnt/hda2/remaster/etc/X11

If currently in KDE environment

If you performed the first half of this HOWTO from within KDE, then you must follow these steps. If you performed the first half of the HOWTO from console command line session, then DO NOT DO THESE STEPS!

Exit the chroot by typing exit or <CTRL-D>. Exit the menu by choosing option 6 "Quit the program." Use the following command to go to runlevel 2.

init 2

It will close KDE and leave you at a command prompt. (It may appear hung, but press Enter and you should see the command prompt.

cd /mnt/hda2/scripts
./knoppix-remaster /mnt/hda2/remaster
  1. Choose "No", I do not want to create a new remaster.
  2. Hit <ENTER> to choose the path /mnt/hda2/remaster as default.
  3. Choose the chroot option to enter the chroot. This section is complete.

Finally start graphical environment

NOTE for noppix 3.8.1 and higher: You may need to change the permissions of /tmp to full read/write and execute. If you do not, then KDE might not run.

chmod 777 /tmp

END NOTE

Become the user knoppix and startx

su - knoppix

(If you get a /dev/null permissions problem do

chmod 666 /dev/null
exit
su - knoppix

)

Start X which will start KDE and bring us to a graphical desktop

startx

Now that it is in the GUI, you can change the fonts, disable the menu translucency and the konsole translucency.

You can use synaptic to add packages like mozilla firefox, openoffice.org, vncviewer, kdeartwork which contains the Plastik widget style, and you can even update the window manager. If you do update all or parts of KDE, it is suggested that I exit KDE (close session), drop back to the command prompt and rerun startx to make sure it is applied.

When you are happy with all the changes that you have made, then it is time to exit .

  1. Exit (close session) and I am dropped back at the prompt.
  2. Type exit to exit my session as the user knoppix and you are now root.

Other customizations

To keep certain desktop settings persistent

I must now mention the file /etc/X11/Xsession.d/45xsession. This script controls how knoppix behaves & how knoppix creates the knoppix user's home directory.

Edit the file /etc/X11/Xsession.d/45xsession and look for the ninth occurence of rsync in the script and it is found at or around line 128:

126: if [ -z "$DONTCHANGE" ]; then
127: # No persistent homedir, copy everything
128: rsync -Ha --ignore-existing /etc/skel/{.kde*,Desktop} $HOME/ 2>/dev/null
129: [ "$USER" = "knoppix" ] && rsync -Ha --ignore-existing /usr/share/knoppix/profile/{.kde*,Desktop} $HOME/ 2>/dev/null


It is line 128 which populates the /home/knoppix folder. So In line 128, I delete from & including the { to the }. It is changed as follows.

126: if [ -z "$DONTCHANGE" ]; then
127: # No persistent homedir, copy everything
128: rsync -Ha --ignore-existing /etc/skel/ $HOME/ 2>/dev/null
129: [ "$USER" = "knoppix" ] && rsync -Ha --ignore-existing /usr/share/knoppix/profile/{.kde*,Desktop} $HOME/ 2>/dev/null

Make the change and save the 45xsession file.

Backing up chroot environment

This assumes that you have at least 3GB of additional free hard disk space. At this point you may want to make a safe backup copy of all the changes that you have made. If you do not want to make a backup copy then skip this part.

  1. Exit the chroot by either typing exit or using the keyboard <CTRL-D>.
  2. Now back at the menu, choose option 6, and quit the program.
  3. Next you may need to mount the drive that you have space on for backups, in our example: hdb1
mount -t ext3 /dev/hdb1 /mnt/hdb1

Now copy the whole remaster to hdb1 (or some other place) for safe keeping:

cp -Rp /mnt/hda2/remaster /mnt/hdb1/backup-remaster
  1. When that is complete I rerun the knoppix-remaster command and tell it "No", I do not want to create a new remaster.
  2. Hit <ENTER> to choose the path /mnt/hda2/remaster as default.
./knoppix-remaster /mnt/hda2/remaster

I choose option 1 and chroot into the remaster.

Final manual cleanup steps

NOTE: The rest of the steps are written with the assumption that it is being done from runlevel 2. However they can be done within KDE by typing init 5, running the knoppix-remaster script, and then chroot into the remaster.

Now you need to make the changes to the system so that the knoppix CD will boot without errors. As a reminder, these commands need to be done inside the chroot, virtual terminal 1 <ALT-F1>.

Delete the existing /etc/skel.

rm -rf /etc/skel

Move /home/knoppix to /etc.

mv /home/knoppix /etc/skel

Change the owner back to root.

chown -R root:root /etc/skel

Remove the XF86Config-4 file as it will get recreated on every bootup.

rm /etc/X11/XF86Config-4

If you had to change the permissions for /tmp then change them back:

chmod 555 /tmp

Enter the following command to clean up the downloaded .deb packages.

apt-get clean

I want to remove any traces of recently used programs in KDE so I edit /etc/skel/.kde/share/config/kickerrc and I find the field that reads something like

RecentAppsStat=9 1096000374 /usr/share/applications/mozilla.desktop

I edit the line and leave the end blank

RecentAppsStat=
  1. Exit the chroot by either typing exit or using the keyboard <CTRL-D> and fliping back to virtual terminal 2 <ALT-F2>

If you are paranoid delete /mnt/hda2/remaster/etc/skel/.bash_history & delete /mnt/hda2/remaster/root/.bash_history.

rm /mnt/hda2/remaster/etc/skel/.bash_history /mnt/hda2/remaster/root/.bash_history

Create the compressed filesystem

Flip back to virtual terminal 1 <ALT-F1> and run the knoppix-remaster script.

./knoppix-remaster /mnt/hda2/remaster

I choose option 2 "Create compressed fs".

It will ask me "Do you want to cleanup your remaster?" & I choose yes.

NOTE: a remaster filesystem of about 2.1GB compresses down to about 685MB CD ISO. You can check the system size by issuing the commands df -h or du -h --max-depth=1.

At this point it is fully automated and will create compressed Knoppix filesystem that is found on the Knoppix CD.

Example compression times:

  • Pentium 3 - 450 MHz 384MB aprox. 1hr 15min
  • Duron 1.6 GHz 768MB RAM aprox. 25 min
  • Opteron 242 (1.4GHz) 1GB RAM aprox 12 min

Create ISO image

When the compressed filesystem step is complete, choose option 3 "Create isofs" to create the ISO file. Again, through the wonders of these scripts, it is all automated. Once that step is complete, choose the option 6 & quite the program.

The finished ISO file, for this example, is located at /mnt/hda2/remaster/Knoppix.build/Knoppix.Master/KNOPPIX-CUSTOM.iso.

Burn ISO image

At this point burn the ISO to CD. If you have an available CDRW drive in your system like /dev/hdd, then type init 5 to go to runlevel 5 where it runs KDE and you can burn the CD with K3B. Or you can burn the CD from the command line. First get the CDRW device ID numbers via

cdrecord -scanbus

It will scan your system and display a list of devices. Identify the ID numbers in form #,#,#. This example will use 1,1,0. Load the CDRW drive with a blank CDR and use the command below to burn the ISO to the CDR.

cdrecord -v gracetime=2 dev=1,1,0 speed=32 -dao driveropts=burnfree -eject -data /mnt/hda2/remaster/Knoppix.build/Knoppix.Master/KNOPPIX-CUSTOM.iso

If you do not have a available CDRW drive, then perhaps you can boot into the graphical KDE environment via init 5. In KDE you can use the Knoppix menu and start the samba service to permit sharing of the hard drives via Windows network filesharing. Or you can copy the ISO to a FAT32 partition. Or scp it somewhere, etc.