TOPDIR=`pwd`
-mkdir -p /mnt/loop1 /mnt/loop2
-
-#
-# we need to set aside a few loop devices. I chose (in reverse order of their appearance)
-# -- loop1 for the boot image
-# -- loop2 for the RAM disk image
-# since the loop1 choice is reflected in the lilo.loopfix file,
-# you should not change that (or you need to change the file).
-# I had used loop0 first, but I found that this is used by the Samba daemon.
-# Also, I assume that the mount points are /mnt/loop{1,2}.
-# In principle we could do with one, but it comes in handy to be able to
-# leave one mounted, so I took two different ones.
+LOOP2=/tmp/bacula_rescue_loop2
+rm -rf $LOOP2
+mkdir -p $LOOP2
# Assume that everything to be loaded into memory with the
# RAM disk image (initrd) is is in the roottree directory.
dd if=/dev/zero of=$TOPDIR/root bs=1k count=$ISIZE
-umount /mnt/loop2 2>/dev/null >/dev/null
+# cleanup any prior left over stuff
+umount $LOOP2 2>/dev/null >/dev/null
losetup -d /dev/loop2 2>/dev/null >/dev/null
# associate it with /dev/loop2
fi
# we mount it...
-mount /dev/loop2 /mnt/loop2
-
+mount /dev/loop2 $LOOP2
# ... and delete the lost+found directory
-rm -rf /mnt/loop2/lost+found
+rm -rf $LOOP2/lost+found
# then we copy the contents of our roottree to this filesystem
-cp -dpR roottree/* /mnt/loop2/
-if [ $? != 0 ] ; then
- echo "RAM disk build failed."
- exit 1
-fi
+cp -dpR roottree/* $LOOP2/
+cprtn=$?
# and unmount and divorce /dev/loop2
-umount /mnt/loop2
+umount $LOOP2
losetup -d /dev/loop2
+rm -rf $LOOP2
+
+# If above copy failed, bail out
+if [ $cprtn != 0 ] ; then
+ echo "RAM disk build failed."
+ exit 1
+fi
+# This is a newer way of creating a ramfs, which we don't use
# (cd roottree; find . | cpio --quiet -c -o) >root
echo "Building initial RAM disk done"