Patch for knoppix-mkimage
Hi all,
Today I used Knoppix-5.3.1 for a while and then decided to create a persistent
KNOPPIX disk image.
My first attempt failed with an error message from rsync that there is no
space left on the device. I tried increasing the disk image size again and
again but it did not help. Then I noticed that the path names in the rsync
error message became longer and longer and looked like an endless recursion.
At this point in time I started to investigate this issue a little more...
knoppix-mkimage mounts the disk image to /tmp/knxhome and uses this directory
as the destination when rsync'ing /ramdisk. There is one central issue
here: /tmp/knxhome is a subdirectory of /ramdisk. So basically, you are
rsyncing a directory to one of its own subdirectories. In previous versions
of Knoppix this was probably not really a problem, because older versions of
rsync first get a complete file-list and then start to copy files. But, since
version 3.0 rsync uses a feature called "incremental file-list recursion". It
just looks up some files, transfers them, looks up the next bunch of files,
etc. Now you probably see the problem: When /ramdisk contains much more files
than rsync catches with its first file-list creation round and rsync finally
reaches /ramdisk/tmp/knxhome it considers the already copied files as new
files to be copied. Eternal recursion starts and the universe collapses. :-)
You can reproduce this bug by booting Knoppix, creating a lot of files in your
home directory (i.e. surf the web for a while, install some software packages
or unpack some source packages) and try creating the persistent disk image.
I fixed this bug by using /tmp_knxhome as mount point for the disk image (see
attached patch). I am not a l33t shell script h4xor, not at all. I don't know
if I did everything right. Please take a look.
Greetings
Ronny
--- knoppix-mkimage.original 2008-04-26 08:13:58.498639618 +0200
+++ knoppix-mkimage 2008-04-26 08:17:03.212588966 +0200
@@ -346,14 +346,16 @@
# Start progress display and copy data
gauge "$MESSAGE9" &
mke2fs -m0 "$LOOPDEV" 2>"$TMP.err" || { killgauge; $DIALOG --cr-wrap --title "$TITLE1" --msgbox "$ERROR `cat $TMP.err`" 10 75; bailout; }
-mkdir -p /tmp/knxhome
-mount -t ext2 "$LOOPDEV" /tmp/knxhome 2>"$TMP.err" && rsync --exclude /ramdisk/var/tmp/ --exclude /ramdisk/etc/mtab --exclude /etc/mtab -Ha /ramdisk/ /tmp/knxhome 2>"$TMP.err" || { umount /tmp/knxhome 2>/dev/null; killgauge; $DIALOG --cr-wrap --title "$TITLE1" --msgbox "$ERROR `cat $TMP.err`" 10 75; bailout; }
+MOUNT_POINT=/tmp_knxhome
+mkdir -p $MOUNT_POINT
+mount -t ext2 "$LOOPDEV" $MOUNT_POINT 2>"$TMP.err" && rsync --exclude /ramdisk/var/tmp/ --exclude /ramdisk/etc/mtab --exclude /etc/mtab -Ha /ramdisk/ $MOUNT_POINT 2>"$TMP.err" || { umount $MOUNT_POINT 2>/dev/null; killgauge; $DIALOG --cr-wrap --title "$TITLE1" --msgbox "$ERROR `cat $TMP.err`" 10 75; bailout; }
# Save knoppix.sh script ?
# Rather add some links in the network/printer configuration scripts that go to the pesistent homedir.
# Finish
-umount /tmp/knxhome
+umount $MOUNT_POINT
+rmdir $MOUNT_POINT
[ -n "$LOOPDEV" ] && losetup -d "$LOOPDEV"
umount "$DIRECTORY" 2>/dev/null
killgauge
Reply to: