Here is the beginning of the remaster script for Modularity (www.modularity.org):

Code:
# $Image -- name of the iso to be remastered
# $hd_part -- Partition to be remastered
# $swapfile -- Location\name of swap file
Image=/mnt/modelk-0.5.2.iso
hd_part=hda8
swapfile=/tmp/knx-swapfile
cd /tmp

#Setup tmp 2K (2000M) swap file

swapoff $swapfile

echo "Creating 2Gig Temperary Swap File in /tmp as knx-swapfile"
dd if=/dev/zero of=$swapfile bs=1M count=2000 && sync && sync

# creates a 2G (2000M) swapfile in /tmp/

echo "Initializing Swap"
mkswap $swapfile    # (initializes /swapfile)
swapon $swapfile    # (turn on new swap)
echo "Swap enabled"

echo "Setting up file system"
mkfs /dev/$hd_part
mount /dev/$hd_part /mnt/$hd_part
echo "Mounting CD-ROM Image as loop back device"
mkdir /mnt/$hd_part/tmp

mkdir /mnt/$hd_part/tmp/CDROM

echo "Mounting CD-ROM iso to tmp"
mount -o loop $Image /mnt/$hd_part/tmp/CDROM
echo "Coping files from loop mounted .iso to CDROM directory of harddrive"
cp -Rp /mnt/$hd_part/tmp/CDROM /mnt/$hd_part/
echo "Copying complete"
echo "Unmounting .iso loop back"
umount $Image
rm /mnt/$hd_part/tmp/CDROM

mkdir /mnt/$hd_part/tmp/WORKING

echo "Extracting KNOPPIX compressed file system"
extract_compressed_fs /mnt/$hd_part/CDROM/KNOPPIX/KNOPPIX > /tmp/UNCOMPRESSED
echo "Mounting UNCOMPRESSED cloop (compressed file system) to loopback device"
mount -o loop /tmp/UNCOMPRESSED /mnt/$hd_part/tmp/WORKING
#rsync -plarv   /mnt/$hd_part/tmp/WORKING /mnt/$hd_part/
echo "Copying files from cloop to hard drive"
cp -Rp /mnt/$hd_part/tmp/WORKING /mnt/$hd_part/

echo "Cleaning up"
umount /mnt/$hd_part/tmp/WORKING
rm /tmp/UNCOMPRESSED

#rm /mnt/$hd_part/tmp/UNCOMPRESSED
rm /mnt/$hd_part/CDROM/KNOPPIX/KNOPPIX

echo " Ready to chroot to Knoppix"
echo "To begin -- Type chroot /mnt/hda?/WORKING"