5 LOOP2=/tmp/bacula_rescue_loop2
9 # Assume that everything to be loaded into memory with the
10 # RAM disk image (initrd) is is in the roottree directory.
12 echo "Creating the Initial RAM disk image.... "
14 # first find out how much space we need.
15 ISIZE=`du -s -k roottree/ | awk '{print $1}'`
18 ISIZE=`expr $ISIZE + 2048`
19 echo "Initial RAM disk contents will be $ISIZE KB"
21 # delete the existing RAM disk image, if there is one
24 dd if=/dev/zero of=$TOPDIR/root bs=1k count=$ISIZE
26 # cleanup any prior left over stuff
27 umount $LOOP2 2>/dev/null >/dev/null
28 losetup -d /dev/loop2 2>/dev/null >/dev/null
30 # associate it with /dev/loop2
31 losetup /dev/loop2 $TOPDIR/root
33 # make an ext2 filesystem on it. Set reserve to 0
34 mke2fs -q -m 0 /dev/loop2 $ISIZE
41 mount /dev/loop2 $LOOP2
42 # ... and delete the lost+found directory
43 rm -rf $LOOP2/lost+found
45 # then we copy the contents of our roottree to this filesystem
46 cp -dpR roottree/* $LOOP2/
49 # and unmount and divorce /dev/loop2
54 # If above copy failed, bail out
55 if [ $cprtn != 0 ] ; then
56 echo "RAM disk build failed."
60 # This is a newer way of creating a ramfs, which we don't use
61 # (cd roottree; find . | cpio --quiet -c -o) >root
63 echo "Building initial RAM disk done"
65 # Now we have the image of the RAM disk in $TOPDIR/loopfiles/root. We
66 # compress this one and write the compressed image to the boot tree:
68 echo "Compressing the RAM disk image.... "
70 # delete any existing one
71 rm -f cdtree/boot/isolinux/initrd.img
73 # and gzip our RAM disk image and put it in the right place.
74 gzip -9 -c root >cdtree/boot/isolinux/initrd.img
80 rdsize=`expr $ISIZE \* 1024`
81 echo "Ramdisk size is $rdsize"
83 echo "Making isolinux.cfg"
84 cat >cdtree/boot/isolinux/isolinux.cfg <<END_OF_DATA
95 append ramdisk_size=$rdsize initrd=initrd.img
101 # we are done with the RAM disk image, delete it
104 echo "Initial RAM disk initrd.img is built."