]> git.sur5r.net Git - bacula/rescue/blobdiff - rescue/linux/cdrom/makeinitrd
Some updates
[bacula/rescue] / rescue / linux / cdrom / makeinitrd
index e5e87dc1bab4f9f7878fba500f466eecc8b8c2fe..e543af8e08e29a24962c3f87b77504e6bc595fd8 100755 (executable)
@@ -2,17 +2,9 @@
 
 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. 
@@ -31,7 +23,8 @@ rm -f root
 
 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
@@ -45,22 +38,26 @@ if [ $? != 0 ] ; then
 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"
@@ -74,8 +71,7 @@ echo "Compressing the RAM disk image.... "
 rm -f cdtree/boot/isolinux/initrd.img
 
 # and gzip our RAM disk image and put it in the right place.
-# gzip -9 -c root >cdtree/boot/isolinux/initrd.img
-gzip -9 < root >cdtree/boot/isolinux/initrd.img
+gzip -9 -c root >cdtree/boot/isolinux/initrd.img
 if [ $? != 0 ] ; then
   echo "Build failed"
   exit 1