From: Manuel Franceschini Date: Mon, 30 Jun 2008 14:58:51 +0000 (+0000) Subject: Modify os scripts to mount file disks correctly X-Git-Tag: v0.5~12 X-Git-Url: http://git.equinoxoli.org/?p=ext%2Finstance-debootstrap.git;a=commitdiff_plain;h=656f0ff5b5cde974094c3a6b0b14a5129606d02c Modify os scripts to mount file disks correctly This patch adds a conditional statement before mounting the with -b given device to detect if it is a block device or a regular file. In the former case it mounts it regularly, in the latter it tries to mount it via loopback device. Reviewed-by: iustinp --- diff --git a/create b/create index 9bede89..562fa7d 100755 --- a/create +++ b/create @@ -54,7 +54,14 @@ mkswap $swapdev mke2fs -Fjq $blockdev TMPDIR=`mktemp -d` || exit 1 trap "umount $TMPDIR; rmdir $TMPDIR" EXIT -mount $blockdev $TMPDIR + +# If it's not a block device try to mount it via loopback device. +# This is needed for file disks. +MOUNT_OPTIONS="" +if [ ! -b $blockdev ]; then + MOUNT_OPTIONS="$MOUNT_OPTIONS -o loop" +fi +mount $MOUNT_OPTIONS $blockdev $TMPDIR # remove the cache file if it's old (> 2 weeks) and writable by the owner (the # default due to the standard umask) diff --git a/import b/import index 2803756..a287644 100755 --- a/import +++ b/import @@ -48,7 +48,15 @@ mkswap $swapdev mke2fs -Fjq $blockdev TMPDIR=`mktemp -d` || exit 1 trap "umount $TMPDIR; rmdir $TMPDIR" EXIT -mount $blockdev $TMPDIR + +# If it's not a block device try to mount it via loopback device. +# This is needed for file disks. +MOUNT_OPTIONS="" +if [ ! -b $blockdev ]; then + MOUNT_OPTIONS="$MOUNT_OPTIONS -o loop" +fi +mount $MOUNT_OPTIONS $blockdev $TMPDIR + ( cd $TMPDIR; restore -r -y -f - ) rm -f $TMPDIR/etc/udev/rules.d/z25_persistent-net.rules umount $TMPDIR diff --git a/rename b/rename index 9c13ddd..66c5409 100755 --- a/rename +++ b/rename @@ -48,7 +48,14 @@ fi TMPDIR=`mktemp -d` || exit 1 trap "umount $TMPDIR; rmdir $TMPDIR" EXIT -mount $blockdev $TMPDIR + +# If it's not a block device try to mount it via loopback device. +# This is needed for file disks. +MOUNT_OPTIONS="" +if [ ! -b $blockdev ]; then + MOUNT_OPTIONS="$MOUNT_OPTIONS -o loop" +fi +mount $MOUNT_OPTIONS $blockdev $TMPDIR HNAME="$TMPDIR/etc/hostname" MNAME="$TMPDIR/etc/mailname"