std-logo

STD 0.1
security tools distribution
MD5: de03204ea5777d0e5fd6eb97b43034cb

Home
-
Download
-
Forum
-
FAQ
-
MD5
-
STD Tools
-
CDs, tshirts, etc
-
Docs
-
Donate
-
Change Log
-
Screenshots
-
Graphics
-
Links

How to Customize Knoppix-STD

This article will walk you through the process I used to create Knoppix-STD. Knoppix-STD is a customization of the standard Knoppix distribution. As such it owes everything to the work already done by Klaus Knopper and borrows heavily from work done by the regulars over at www.knoppix.net. In fact, knoppix.net is the first place to go if you're looking for information on how to customize. I used a hybrid of information available from the following links:

The official knoppix.net howto : http://www.knoppix.net/docs/index.php/KnoppixRemasteringHowto
Sunil Thomas Thonikuzhiyil's howto : http://gnubox.dyndns.org:8080/~sunil/knoppix.php
Knoppix Customization Forum :
http://knoppix.net/http://forum.s-t-d.org/viewforum.php?f=2

and thanks to blivius for posting Klaus's scripts and how to use them.

I didn't take fantastic notes, but this is what I remember. There is a lot of trial and error involved and you will probably be bouncing back and forth between this document and the links above. Expect to waste many a CD your first several times. O.K., now if memory serves.....



Getting Started

Before you start you'll need the following:

The Knoppix distribution you want to use as a template like Knoppix-STD
A machine that can boot to Knoppix
7-8GB of free disk space
A CD Burner
A big stack of blank Cds
A willingness to get your knuckles bloody learning Linux
A boat load of patience

I'm going to assume Knoppix-STD from here on out, but you can really use any of the various Knoppix customizations as a base. So let's get to it.

First boot to STD. In a shell, get root by typing 'rootme'.



Setting Up the Partitions

You'll need at least two partitions, but I use three as follows (your partition numbers (hdaX) might be different). You can use 'cfdisk' to create them.

hda1 : 4GB : ext2 : This is for your custom STD filesystem and the iso filesystem you'll use to create the CD. Various FAQs suggest anywhere from 3-6GB. I used slightly over 3GB in making STD 0.1b, so I suggest 4GB. Of course harddrives are cheap these days. If you can afford 5GB, go for it. If you don't use it all it won't affect the end image.

hda2 : 2GB : ext2 : Optional, but this is where I keep various programs and scripts I want to add. This is where I do compiling, testing, archiving, etc..

hda3 : 1GB : linux swap : Actually, it's suggested that you have at least 1GB of memory total. So however much less than that your physical RAM is, you'll have to make up for in swap. If you have 256MB RAM, you'll need 768MB in swap to equal a gig. To be safe just make your swap a GB and call it a day.

To format the partitions:

mkfs.ext2 /dev/hda1
mkfs.ext2 /dev/hda2
mkswap /dev/hda3

Populate the Partition

Your chroot'ed environment under /mnt/hda1

/--bin                    <-------- the root of the STD filesystem. 
/--boot
/--cdrom
/--dev
/--etc
/--floppy
/--home
/-- (all the rest)
/--KNOPPIX.build
       |--Knoppix.clean   <-------- scripts to create the compressed fs
       |--Knoppix.mkcompressed
       |--Knoppix. Postupgrade
       /--cdrom           <-------- this will be the root of the CD
            |--STD.jpg
            |--autorun.bat
            |--autorun.inf
            |--cdrom.ico
            |--index.html
            |--version
            /--KNOPPIX
                  |--KNOPPIX   <-------- this is the compressed fs
                  |--KNOPPIX-FAQ.txt
                  |--README_Security.txt
                  |--background.jpg
                  |--boot.img
                  |--index.html
                  |--knoppix-cheatcodes.txt
                  |--mkfloppy.bat
                  |--(bunch of other files)
      

 

As shown above, you'll be working with two filesystems on hda1. The first one will be the STD filesystem where you'll make your modifications. The second one will be the iso filesystem that'll you'll burn to CD. But first, if you haven't rebooted, turn on your swap partition:

swapon /dev/hda3

After a reboot, Knoppix will mount the swap file automatically. Mount hda1 and hda2 read/write with:

mount -o rw /dev/hda1 /mnt/hda1
mount -o rw /dev/hda2 /mnt/hda2

hda1 is where you'll be doing most all of your work. You'll need the existing STD filesystem so we can modify it. The base filesystem resides under /KNOPPIX/ when you're booted to STD., so copy it over to the harddrive:

cp -Rp /KNOPPIX/* /mnt/hda1

This will take awhile so go grab a cup of coffee.... mmmmm.... coffee... Whew. Alright, next set up the iso filesystem. Create three directories under hda1 like so:

mkdir /mnt/hda1/KNOPPIX.build
mkdir /mnt/hda1/KNOPPIX.build/cdrom
mkdir /mnt/hda1/KNOPPIX.build/cdrom/KNOPPIX

copy the following scripts into KNOPPIX.build:

Knoppix.clean
Knoppix.mkcompressed
Knoppix.postupgrade

Make sure they have execute permissions. These will create your compressed filesystem (/cdrom/KNOPPIX/KNOPPIX) after you're done customizing. Now copy all of the original files from the CD to the KNOPPIX.build/cdrom directory except the /cdrom/KNOPPIX/KNOPPIX compressed filesystem. The CD is located under /cdrom when booted to STD and /mnt/hda1/KNOPPIX.build/cdrom will be the root of the iso that you'll eventually burn to CD.

cp -p /cdrom/*.* /mnt/hda1/KNOPPIX.build/cdrom
cp -p /cdrom/KNOPPIX/*.* /mnt/hda1/KNOPPIX.build/cdrom/KNOPPIX



CHROOT

Before you can customize you'll need to chroot into what will be the root of your new filesystem:

chroot /mnt/hda1

Mount proc in your chroot'ed environment:

mount -t proc /proc proc

If you already have an internet connection setup it will still be active in your chroot'ed environment, but you'll need to edit your resolv.conf file in order to get name resolution:

echo nameserver W.X.Y.Z >> /etc/resolv.conf

where W.X.Y.Z is your dns server.



Customize

Now you can start your customization.

Remove Apps: First remove any applications you no longer want:

apt-get remove package-name

To decide which packages you want to uninstall try using kpackage to see what's installed and make a list before you start customizing. Check out Sunil's website for a list of applications to start with. You'll also want to run:

deborphan

To see packages that you no longer need.

Add Apps: Inside the chroot'ed environment install applications as you normally would. Compile, use install scripts, or run apt-get install package-name.

Edit your preferences: The preferences for the knoppix user account are set under /etc/skel/. For instance, the KDE K-Menu can be found under: /etc/skel/.kde/share/applnk/. This gets copied to the /home/knoppix directory on boot. Other preferences you might want to configure:

/etc/init.d/knoppix-autoconfig : knoppix boot options, like which windows manager to load
/etc/skel/.mozilla/knoppix/ujixazk6.slt/bookmarks.html
: Mozilla bookmarks
/etc/skel/.kde/share/config/kickerrc : KDE Kicker panel
/usr/local/lib/knoppix.jpg and /cdrom/KNOPPIX/background.jpg : background image : 1024x768
/usr/share/apps/ksplash/pics/splash_top.png : KDE loading splash screen : 400x244

You can also create users and set passwords while in the chroot'ed environment.

Clean Up: the compression scripts you'll be running in a second probably do a great job of clean up, but just to be sure remove any .preferencefiles from the /root dir that you don't want on the CD (e.g. .bash_history). Also get rid of everything in /var/cache/apt/archives.

Umount /proc: uh, yeah., run: umount /proc



Create the KNOPPIX compressed filesystem

Now that you have the filesystem with the directories, preferences, and applications you want, it's time to compress it so you can fit it on a CD. The entire filesystem will be compressed into a single file called KNOPPIX and will be placed on the CD in the KNOPPIX directory (/cdrom/KNOPPIX/KNOPPIX). To do this you'll use Klaus's scripts in the KNOPPIX.build directory. Only do this in the chroot'ed environment.

cd to the KNOPPIX.build directory and run:

./Knoppix.mkcompressed /KNOPPIX.build/cdrom

Follow the prompts and then it's time to wait some more. This could take about an hour. After it completes compressing the STD fs to the KNOPPIX file you will be asked for the name of the iso. It will fail with an error, but that's o.k.. We're only using it to make the filesystem. We'll make the iso in a second. One day I'll dig through the scripts and make them work a little cleaner.



Modifying your boot options

Before you actually create the CD, you might also want to change some of the default boot options, like what directories and symbolic links are created, or the boot splash screen. All of these options are handled by the boot image: /cdrom/KNOPPIX/boot.img. You'll want to make these modifications outside of the chroot'ed environment. Exit with a CTL-D.

Copy and mount the boot image:

cp /cdrom/KNOPPIX/boot.img /mnt/hda2
mkdir /mnt/hda2/boot-floppy
mount -o loop /mnt/hda2/boot.img /mnt/hda2/boot-floppy

Now you can dig around the boot image and make any changes you like. Things of interest:

The boot logo : The boot image is logo.16 and is a lss16 format image. To start make a 16 color image you want to use. The image must be 640x480 or less. 640x400 leaves room at the bottom for the boot prompt. Save the image as a bmp format. Then run:

bmptoppm mylogo.bmp > logo16.ppm
ppmtolss16 < logo16.ppm > logo.16

Now copy logo.16 to /mnt/hda2/boot-floppy/

Change the cheatcodes or default boot options: Would you like your version of Knoppix to always mount your permanent home directory or load some driver without providing the cheatcode? Then step right up and edit syslinux.cfg

Modify your initial boot environment: For most everything else you'll want to modify miniroot.gz.

mkdir /mnt/hda2/mini
cp /mnt/hda2/boot-floppy/miniroot.gz /mnt/hda2/
gunzip miniroot.gz
mount -o loop /mnt/hda2/miniroot /mnt/hda2/mini

Now you can dig around in the mini directory to make changes to minroot. linuxrc is the primary target here.

After you make any changes umount miniroot and copy it back to the boot image.

umount /mnt/hda2/mini
gzip /mnt/hda2/miniroot
cp /mnt/hda2/miniroot.gz /mnt/hda2/boot-floppy/

Wrap it all up: To wrap all of your changes up simply unmount and copy it to the cdrom directory

umount /mnt/hda2/boot-floppy/
cp /mnt/hda2/boot.img /mnt/hda1/KNOPPIX.build/cdrom/KNOPPIX/



Make the iso image

Well since the blivius script to create the compressed KNOPPIX fs failed to also make the iso image, we'll have to do it ourselves. If you haven't yet, exit out of the chrooted environment with a CTL-D, then change into the /mnt/hda1/KNOPPIX.build/cdrom directory. Run the following all on one command line.

mkisofs -pad -l -r -J -v -V "Knoppix-STD" -b KNOPPIX/boot.img -c KNOPPIX/boot.cat -hide-rr-moved -o /mnt/hda1/KNOPPIX.build/knoppix-std.iso /mnt/hda1/KNOPPIX.build/cdrom

After another wait, you'll have a burnable iso image waiting for you as /mnt/hda1/KNOPPIX.build/knoppix-std.iso


Burn the CD

There's a built in CD burning GUI called K3b. Launch it from K > Utilities > System > K3b. Burn the iso from Tools > Write ISO image

Probably easier is to just burn from the command line. Find the address of your CD burner using:

cdrecord -scanbus
cdrecord dev=1,0,0 knoppix-std.iso
replacing dev=1,0,0 with the address that your CD burner shows up as.


10 Print "modest mouse rulz"
20 Goto 10

This is the point where you start all over, because if your customization works perfectly on the first burn you're one lucky SOB. As I fine tune my process, I'll update this document. If you've found a better method than what I explain here, please forward it along and I'll include it here.