[ FloobyDust ][ Previous ]
Knoppix Remaster
Updated 2007.11.30
Introduction
I was able to put Knoppix 4.0.2 on a bootable 1G USB flash drive (see Knoppix on USB Flash) but I wanted to remove some large packages to make more room for my own data on the flash drive. I also added ntfs read/write support (a different approach than the one that comes with 4.0.2) and a tool for manipulating the Windows registry and resetting Windows passwords and some wrapper scripts to make them a little easier to use from the KDE GUI. The Windows tools have proved useful to a friend who does Windows recovery and repair. Now there's a growth industry ;)
Update 2007.11.30: With Knoppix 5.1.1 the built-in NTFS tools seem robust so I didn't need to add that capability. The chntpw Windows registry tool was added via apt-get from the Debian repository so it gets included in the base system and doesn't need a convenience wrapper. Given that, I didn't need to modify the KDE menus. I _did_ add some bootable floppy images to the isolinux menu - external to the Knoppix build - that got included in the final CD image. They were all hard drive diagnosis, repair, and parititioning tools.
To personalize the result I customized the KDE menu, added a little documentation, and customized the boot menus and artwork, as well as the html page that comes up when Knoppix is booted (or plugged into a Windows box).
The tools and personalization were installed on a custom live-CD version then transferred to USB flash. I put the necessary GRUB boot loader files in the CD version to make the transfer as simple as possible.
Remastering
I'm not going to go into all the details of the remastering process here. I pretty much followed the instructions detailed at www.knoppix.net/wiki/Knoppix_Remastering_Howto to the letter, and incorporated some of the suggestions at www.knoppix.net/wiki/Remastering_Hacks.
Basic Knoppix remastering as described in the excellent howto involves copying a running live-CD Knoppix uncompressed to a "source" directory and creating a "master" directory to receive the remastered version with the compressed KNOPPIX filesystem. Changes to the Knoppix packages and anything else that is within the compressed KNOPPIX filesystem are done to the "source" (some while chroot-ed into the "source") while changes to things outside the KNOPPIX filesystem - such as boot files - are made to the "master".
Using the techniques described in the HOWTO and HACKS, I removed the following packages. This was done while chroot-ed to the "source" directory using "apt-get remove <package name>".
(size of space freed - in the uncompressed form - compressed space will be less)
openoffice-de-en (307MB)
emacs21-common (42MB)
libwine (49MB)
scribus (14.4MB)
enigma-data (23MB)
gimp-data (23MB)
kstars-data (23MB)
mysql-server (8MB)
mozilla-thunderbird (32MB)
locales (10MB)
Update 2007.11.30: For the 5.1.1 version I added the chntpw package:
apt-get install chntpw
And the KDE internationalization packages:
kde-i18n-de (37MB)
kde-i18n-es (26MB)
kde-i18n-pl (9MB)
kde-i18n-ja (9MB)
kde-i18n-tr (7MB)
kde-i18n-it (6MB)
kde-i18n-nl (2.5MB)
kde-i18n-fr (2.2MB)
kde-i18n-ru (1.4MB)
Then ran "dpkg-reconfigure locales" to get rid of all except
en_US.ISO-8859-1
en_US.ISO-8859-15 ISO-8859-15
en_US.UTF-8 UTF-8
(and selected en_US as the default locale)
And set the fall-back language to english us by editing /etc/init.d/knoppix-autoconfig and changing
LANGUAGE=de
to
LANGUAGE=us
Finally, I ran deborphan, apt-get clean, unmounted /proc and exited the chroot - all per the HOWTO and HACKS. This resulted in a final compressed KNOPPIX filesystem of approximately 600MB - a 150MB reduction.
NOTE: in order to get the desired customized KDE menu I did some additional manipulation from within the chroot environment - but not during the initial remaster. It was easier (for me anyway) to do the basic remaster, burn a CD-RW, then boot that and do another remaster and edit to get the final result. The additional steps are described below.
Update 2006.06.19: fix a bug that prevents the USB 2.0 driver module from loading before creating the final CD ISO. See Bugs & Fixes, below.
Update 2007.11.30: for the 5.1.1 version I followed the HOWTO and HACKS guides exactly, and other than adding the chntpw package and customizing some graphics I didn't do anything else _internal_ to Knoppix.
NOTE:
The following modifications were made to an already remastered (reduced size) Knoppix burned on a CD-RW created using the above procedure. I rebooted to the new CD-RW and repeated the remastering process using it as the template. The contents of the new CD-RW were copied to the "source" and "master" directories in a repeat of the above procedure - except that I didn't make any changes to the packages. The additional modifications are described below.
Update 2007.11.30: With the 5.1.1 version I didn't modify the KDE menus so the above step wasn't necessary.
In keeping with one of the sillier Linux traditions, I named my remastered and customized Knoppix "BEEZIX".
Added Tools and Docs
Tools
This was mostly a learning exercise but to make it a little more interesting I added tools to mount ntfs partitions read-write (captive-ntfs), and access the Windows registry and reset Windows passwords (chntpw). These should be useful for Windows forensics/rescue/recovery. Knoppix 4.0.2 already includes ntfs read-write support with the Linux-ntfs project, but I got interested in captive-ntfs, and haven't tried the "project" tool.
These additional tools were placed in their own directories: /opt/beezix/captive-ntfs and /opt/beezix/chntpw. I gathered the chntpw documentation text files and placed them in the chntpw directory too.
To (try) to make the tools a little easier to use (and easier to launch from the KDE menu for the "click and drool" set) I wrote some simple scripts to launch captive ntfs installation and uninstall. The install wrapper script runs the captive ntfs install and offers to mount any ntfs partitions that catpive-ntfs finds. The uninstall wrapper first unmounts any mounted ntfs partitions and then uninstalls the captive filesystem driver.
chntpw really needs to be run from the command line. I wrote a "wintool" script that makes that clear and then runs chntpw in its help mode to list the available commands. The script also points the user at the documentation files.
Another pair of scripts open and close the Knoppix firewall. This makes it a lot easier to allow ftp in when trying to move files to another host.
These simple (and probably buggy) scripts are located in /opt/beezix/bin with links from /usr/sbin (links provided to text):
introduce (describe) windows password and registry editor | |
open firewall and restart network | |
restore firewall to previous state | |
install ntfs read/write driver and (optionally) mount partitions | |
unmount ntfs partitions and uninstall driver |
These scripts pause for user input in several places to make them readable (they don't just execute and disappear) when launched from the KDE GUI menu.
Update 2007.11.30: for 5.1.1 I didn't bother with the above additions. I added chntpw via apt-get, and the firewall fiddling isn't necessary after starting the ssh server from the standard Knoppix menu. Captive NTFS isn't needed any more either - the stock tools work well.
Documentation
I put some documentation files (instructions on transferring the CD to USB flash drive and a modified KNOPPIX (BEEZIX) welcome html file) in /opt/beezix/docs. The intention was that they could be launched from the KDE menu or browsed from the command line or file browser. That works fine but I had to duplicate the same things in the root directory of the CD and flash fob so they would also be accessible when just browsing the CD without actually mounting the compressed filesystem. I wasn't sure where the "outside the filesystem" text and html files would show up when running from flash. As it turns out, I could have just linked to the "outside" files at /cdrom and /cdrom/KNOPPIX since it still appears as "/cdrom" whether booted from CD or from USB flash.
Next time I won't duplicate things - there will just be links in /opt/beezix/docs - if the docs directory is used at all - and everything will be at /cdrom or /cdrom/knoppix (or beezix!).
NOTE: the tools, scipts, and links are "inside" the compressed filesystem. They get added to the "source" in uncompressed form and included in the final compressed filesystem. The documentation (in this first go-around) is both inside and outside. One copy went to the "source" in /opt/beezix/docs, and one to the "master" in /knoppix. In the next version, the docs won't be duplicated. Docs useful at boot/browse time will be outside the filesystem and those more appropriate to a running systsem will be "inside" at /opt/beezix/docs.
Update 2007.11.30: for 5.1.1 I just put my doc files in /beezix/docs and didn't fiddle the KDE menus. They are linked from the opening index.html file or accessed directly with the running file browser.
Boot and Graphics Customizations
Graphics and html
The first order of the day was to customize the cdrom icon that shows up when the cd or fob is mounted (on any OS ??). cdrom.ico is just an 80x80 bitmap image (cdrom.bmp) renamed. I used a picture of a wolf-eel. People tell me there is quite a resemblance :) It is located in the root of the cdrom or fob.
Also in the root is index.html. This is used to "autorun" when the CD or fob is mounted or booted. In Knoppix it brings up a splash image and links to the main html file in several languages. I modified the splash (/KNOPPIX/images/knoppix-header.png) to use a picture of my wife swimming with an octopus and trimmed index.html down to just link to my (English) main html file.
The main html file is /KNOPPIX/index_en.html. My version adds a "BEEZIX" introduction, a description of my modifications and additions, links to the captive-ntfs chntpw sites, and links to my documentation to the "stock" Knoppix index_en.html. I modified the background image (/KNOPPIX/images/knoppix-24-1.jpg) to use the wife + octopus photo.
The file /usr/share/apps/ksplash/Themes/Default/splash_top.png provides the splash image displayed while the desktop and other components are getting configured. I used the octopus photo here as well.
The finishing touch to the graphics mods is the desktop background: /KNOPPIX/background.jpg. This is a picture of my boat moored in Bachelor cove. I find it quite soothing.
Oh, and the cherry on top was customized art for the inkjet-printable CD-Rs I used. The (windows) Epson Print CD file is huge (9MB!) so here's the image I used to make it: CD art .
Boot Stuff - isolinux
Not much changed here. Just the boot message and the splash image. The boot message has some magic characters at the beginning that control loading the splash image. I didn't touch them but I did change the splash image and the text. Getting the image right was a pain. It is in lss16 format. There's some information here, and maybe at the Syslinux/Isolinux site.
I started with the wife/octopus and clipped it to 640x400 pixels. This should allow room for the image and the boot message to fit in the boot screen. Then I squashed it to 16 colors and saved it as a .ppm file and converted that to lss16.
Actually it wasn't quite that easy. When isolinux boots in graphics mode (VGA is available) it will use color index 0 for text background and index 7 for text. I wanted the text background to be black, and the text to be light. This required editing the image (once it was squashed to 16 colors) and making sure that index 0 was black - or close to it. I actually edited the image to change the blackest color to actual black, and the whitest color to something acceptable for text.
The next trick is to make sure that the image's color indices end up with 0 for black and 7 for "white". I knew that black was #000000 (hex RGB notation) and I probed the image to get the hex RGB for my "white" (#f3e2cd in my example). The final step was to convert to an lss16 format and force the colors to fall on the correct indices:
ppmtolss16 '#000000=0' '#f3e2cd=7' <bootlogo.ppm >logo.16
DO NOT forget the single quotes or ppmtolss16 will get very confused.
Update 2006.06.19: fix a 4.0.2 bug that prevents the USB 2.0 driver module from loading before creating the final CD ISO. See Bugs & Fixes, below. It is corrected in 5.0.1.
Update 2007.11.30: for the 5.1.1 version I added some bootable floppy images that can be selected from the isolinux boot menu. They get listed by the <F2> option at boot time. Editing the <F2> menu can be a challenge. Here are my boot.msg, isolinux.cfg, and <F2> menu, and here's a useful tool for editing it: Isolinux Mate. Also fixed a but that kept DOS from booting. See below.
Boot Stuff - grub
Grub isn't used when booting the CD but it is when booting the USB flash drive. I put the grub files on the CD to make it easier to transfer everything to the flash drive:
mkdir <master mount point>/boot
mkdir <master mount point>/boot/grub
cp /lib/grub/i386-pc/* <master mount point>/boot/grub/
The grub menu.lst file for BEEZIX is essentially the same as the one I used for the full Knoppix on USB fob installation with the titles changed. Here are the BEEZIX versions showing the added bootable images: (html) menu.lst or (raw text) /boot/grub/menu.lst .
The grub splash image (/boot/grub/bootsplash.xpm.gz) was another pain to build. It is a gzipped xpm graphics file with 14 colors maximum. I started with the octopus image resized to 640x480, squashed to 16 colors, modified the background to be gray instead of black so the overlaid grub menu would be more readable, edited the color table to eliminate two colors (by converting two colors to two similar colors in the table), saved in xpm format, and gzipped. Whew!
NOTE: all the boot and graphics modifications are "outside" the compressed filesystem and get added to the appropriate place in the "master" directory - except /usr/share/apps/ksplash/Themes/Default/splash_top.png which is "inside" and goes in the "source".
Custom KDE Menu
This was a bit of an adventure. There are a lot of posts from people struggling with this. One approach I came across was to run the GUI from within the chroot environment and customize the KDE menu there and save the results. I couldn't get that to work. I finally got it to work with a combination of tips from "Knoppix Hacks" by Kyle Rankin and stuff I found on the Knoppix wiki - including a bug fix in a script. What made it easiest for me was to first do a simple remaster to CD-RW, then boot that and run through the remaster process again - adding my customizations to the already-remastered version.
Running from the new CD-RW (not the chroot environment):
"K"->Configure the Panel->Menus->Edit K Menu
and added a "BEEZIX" submenu (with the wolf-eel icon!) and items to that submenu to launch my scripts and html and text documentation, and saved it. The scripts were set up to launch in a terminal and the docs in Konqueror. I also added the BEEZIX submenu as a panel launcher.
Then (from "Knoppix Hacks"):
sudo rsync -a /home/knoppix/ /<my mount point>/source/KNOPPIX/etc/skel
To move the customizations into my "source". It is necessary to edit a script in the "source" to get the customizations to load correctly when the new remaster is booted. From "Lorenzo" posting at the knoppix.net forum, edit:
/<my mount point>/source/KNOPPIX/etc/X11/Xsession.d/45xsession
and add ".config" at line 64 (both before and after are single lines):
***before***
rsync -Ha --ignore-existing /etc/skel/{.acrorc,.Xdefaults,.gimp*,.gconf*,.bashrc,.nessus*,.links,.local,.lynx*,.qt,.xine,tmp} $HOME/ 2>/dev/null
***after***
rsync -Ha --ignore-existing /etc/skel/{.config,.acrorc,.Xdefaults,.gimp*,.gconf*,.bashrc,.nessus*,.links,.local,.lynx*,.qt,.xine,tmp} $HOME/ 2>/dev/null
It is necessary to make sure that the permissions are correct in /etc/skel/.config and /etc/skel/.local. Contrary to what I read on the wiki, it seems to be necessary to set these and all their sub-directories to 755, and all files to 644 to make things work correctly. If they are incorrect, menu files will probably end up in lost-and-found.
After the above procedure and the other customizations I just finished the remaster and w00t! it all worked when I booted the newest remastered CD and fob!
Update 2007.11.30: with the 5.1.1 version I didn't change the KDE menus since I hadn't really modified the internals of the Knoppix setup other than removing and adding packages. I didn't have to deal with the above. Nice.
Bugs & Fixes - vary with version
DHCP boot hang. Fixed in 5.0.1.
Booting with DHCP enabled will hang the boot on some systems. Seems to be fixed in 5.0.1.
USB 2.0 driver not loaded. Fixed in 5.0.1.
As mentioned in the 4.0.2 bug list, in Knoppix 4.0.2 (fixed in 5.0.1) the USB 2.0 driver isn't loaded at boot due to a typo in linuxrc in the miniroot. This can cause slow USB operation (and booting if via USB) or it can cause the dreaded "Can't find Knoppix filesystem... dropping you to a (very) limited shell" boot failure.
Post-boot (if it boots) just
modprobe ehci-hcd
to load the USB 2.0 driver module. If booting from a USB fob (or drive) just replace /boot/isolinux/miniroot.gz with a corrected version. This file is outside the compressed filesystem so remastering isn't necessary if on a writable filesystem; just copy it to /boot/isolinux/minirt.gz. I have posted my fixed version here: minirt.gz.
NOTE: This is a little surprising, but if I copied minirt.gz to my USB fob (replacing the original file on a fob that had an already-running 4.0.2 install on it) using XP drag-and-drop (click and drool) the file copied OK, but the fob wouldn't boot all the way. It would come almost all the way up and hang at "looking for CD on /dev/sda1". Rewriting the file from Linux fixed it up. No idea if XP was corrupting the copy somehow (probably???) or tweaking the filesystem or ?
Let me know if my repaired minirt works for you - or doesn't.
To fix the miniroot yourself:
Copy /cdrom/boot/isolinux/minirt.gz somewhere handy and gunzip it. Loop mount it:
mount -o loop minirt /mnt/<your mount point>
Edit /mnt/<your mount point>/linuxrc and change the line
USB2="ehci-hcd.ko"
to
USB2="ehci-hcd"
Also add some delay to allow time for the module to load. I added 10 seconds. 5 seconds seemed to be enough, but others recommend 10 and who am I to argue.
...
for i in $USB2 uhci-hcd ohci-hcd; do
test -f /modules/scsi/$i.ko && $INSMOD /modules/scsi/$i.ko >/dev/null 2>&1 && FOUNDUSB="yes"
done
sleep 10 <--- added this
if test -n "$FOUNDUSB"; then
test -f /modules/scsi/ub.ko && $INSMOD /modules/scsi/ub.ko >/dev/null 2>&1
...
Save the edited linuxrc, unmount minirt, gzip it, and copy it to <master mount point>/boot/isolinux/minirt.gz (if remastering) or other appropriate target location.
Free DOS won't boot. (5.1.1)
A missing "memsdisk" entry prevents Free DOS from booting. See Knoppix 5.1.1 Bugs on the wiki.
No CDROM icon on desktop. (5.1.1)
The CDROM icon doesn't appear until some other drive icon is clicked.
USB fob doesn't always automount. (5.1.1)
This varies. A FAT32 will sometimes not automount when plugged in. The error is "can't determine file system type". It can still be manually mounted: mount -t vfat /dev/something /mnt/something
Files Modified
This page is getting pretty long so I moved my list of modified files and their details here.
Errors and Omissions
As always, I appreciate comments and corrections: williamDOTwaddingtonATbeezmoDOTcom. Let me know if any of this is useful.
[ FloobyDust ][ Previous ]