First, make sure you back up all of your data before starting. You'll need root access to your machine.
Part 1. Emulating the CD on the hard drive
Step 1: Create a partition
Create an empty Linux partition of at least 700MB. In my case, I chose to resize and format an existing partition on my second hard drive.
Step 2: Create the directory structure
Mount the newly created partition and create a directory named hardrive_boot.
Insert the Knoppix CD and, as root, copy the /KNOPPIX directory from the CD into the root directory of the partition.
Copy the following files from the CD to the root partition: autorun.bat, cdrom.ico, autorun.inf, and index.html. Remember to preserve the permissions as you copy everything over to the hard drive.
The left side of the panel in Figure 1 shows the CD's directory structure, while the right side shows the hard drive's partition.
Figure 1. Copying files from the CD to the hard drive
Step 3: Copy the boot image
Copy the contents of the compressed kernel image from the CD. Mount the file /KNOPPIX/boot.img on a loop device and copy the contents from the device to /hardrive_boot/. I used these commands:
bash-2.05# /sbin/losetup /dev/loop0 /mnt/linux1/KNOPPIX/boot.img bash-2.05# mount /dev/loop0 /mnt/floppy/ bash-2.05# cp /mnt/floppy/* /mnt/linux1/hardrive_boot
Step 4: Make the partition bootable
Here's an extract of my own LILO configuration. Your instructions will differ if you use something other than LILO.
image = /mnt/linux1/hardrive_boot/vmlinuz label = knoppix initrd = /mnt/linux1/hardrive_boot/miniroot.gz read-only root = /dev/hdc2 append = "lang=us"
Step 5: Update the bootloader (LILO)
Update the bootloader. In my case, this was:
bash-2.05# /sbin/lilo Added linux * Added knoppix Added win2k bash-2.05#
Step 6: Test the installation
Everything is now set and ready to go. Remove the CD and reboot your PC, choosing Knoppix from the bootloader's menu. The system will now behave as it would if booted from the CD.
Part 2. Preparing the Development Environment
Now that you have transferred the Knoppix distribution to the hard drive, it's time to create the development environment. This environment will consist of:
- A working copy of the file system. This is what you will develop.
- An original copy of the file system. This is here just in case you are not satisfied with your remastered version and want to start over.
- The scripts, utilities, and instructions required to create your new live-CD file system and ISO image.
- A swap file in case you don't have enough RAM.
Step 1: Boot the Knoppix partition
You'll copy working copies of the file system to the development hard drive. Don't confuse this with the 710MB partition you created in earlier steps. This will require at least 3GB of space.
Step 2: Create directories
- Create three directories: KNOPPIX_original, KNOPPIX_remastered, and masterISO.
- Enter the masterISO directory and create symbolic links that link to the Knoppix distribution's partition, directory, and file structure that you created in back in part 1.
Figure 2 shows a mix of symbolic and hard links to the real directories and files located on the newly created partition.
Figure 2. The masterISO directory
Step 3: Copy the Knoppix file system
As root, copy the contents of the CD's KNOPPIX expanded directory to the hard drive. It's important to preserve all file attributes to be able to copy the devices. The copying will take a while; now is a good time to order pizza.
bash-2.05# cp -pR /KNOPPIX/* /mnt/hdc1/KNOPPIX_original bash-2.05# cp -pR /mnt/hdc1/KNOPPIX_original/* /mnt/hdc1/KNOPPIX_remastered
Step 4: The scripts
To keep things straight in my head, I created three scripts. createSwap.sh activates the swap drive. You may not need this, but I did.
/sbin/mkswap ./swapfile /sbin/swapon ./swapfile
You can verify that this works by checking the amount of memory you have:
$ free -otm
testDistribution.sh creates a compressed file system using
mkisofs and a utility from the Knoppix distribution called
the current working directory on the development partition. This script
contains the following commands, all on one line (though they've been
reformatted slightly for publication):
mkisofs -R -U -V "PostgreSQL Live CD" -P "email@example.com" -hide-rr-moved -cache-inodes -no-bak -pad ./KNOPPIX_remastered | nice -5 ./create_compressed_fs - 65536 > ./masterISO/KNOPPIX/KNOPPIX
createLiveCD_iso.sh creates the
ISO image that will be burned onto a CD-R. Again, this script contains the following commands, all on one line:
mkisofs -pad -f -l -r -J -v -V "KNOPPIX" -b KNOPPIX/boot.img -c KNOPPIX/boot.cat -hide-rr-moved -o ./knoppix.iso ./masterISO/
Step 5: Create a swap file
If you don't have 1GB of RAM, you'll need a swap file:
bash-2.05# dd if=/dev/zero of=swapfile bs=1024 count=1000000
We've covered a lot of ground so far. You might wonder if it's worth the effort. The short answer is yes. If you want to do serious work and create a great self-booting CD, then you want to let your imagination run wild and try all sorts of ideas. The last thing you want to worry about is the menial command-line stuff or losing valuable time from a disaster compilation.
Figure 3 shows the completed development directory structure.
Figure 3. The completed directory structure