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.... "
13 if test ! -b /dev/loop2; then
14 mknod /dev/loop2 b 7 2
16 echo "Cannot create /dev/loop2"
21 # first find out how much space we need.
22 ISIZE=`du -s -k roottree/ | awk '{print $1}'`
25 ISIZE=`expr $ISIZE + 5120`
26 echo "Initial RAM disk contents will be $ISIZE KB"
28 # delete the existing RAM disk image, if there is one
31 dd if=/dev/zero of=$TOPDIR/root bs=1k count=$ISIZE
33 # cleanup any prior left over stuff
34 umount $LOOP2 2>/dev/null >/dev/null
35 losetup -d /dev/loop2 2>/dev/null >/dev/null
37 # associate it with /dev/loop2
38 losetup /dev/loop2 $TOPDIR/root
40 # make an ext2 filesystem on it. Set reserve to 0
41 mke2fs -q -m 0 /dev/loop2 $ISIZE
48 mount /dev/loop2 $LOOP2
49 # ... and delete the lost+found directory
50 rm -rf $LOOP2/lost+found
52 # then we copy the contents of our roottree to this filesystem
53 cp -dpR roottree/* $LOOP2/
56 # and unmount and divorce /dev/loop2
61 # If above copy failed, bail out
62 if [ $cprtn != 0 ] ; then
63 echo "RAM disk build failed."
68 # This is a newer way of creating a ramfs. Note, it
69 # overwrites the previous root ramdisk that we built.
70 # If you have an older kernel, you may want to comment
73 (cd roottree; find . | cpio --quiet -H newc -o) >root
75 echo "Building initial RAM disk done"
77 # Now we have the image of the RAM disk in $TOPDIR/loopfiles/root. We
78 # compress this one and write the compressed image to the boot tree:
80 echo "Compressing the RAM disk image.... "
82 # delete any existing one
83 rm -f cdtree/boot/isolinux/initrd.img
85 # and gzip our RAM disk image and put it in the right place.
86 gzip -9 -c root >cdtree/boot/isolinux/initrd.img
92 rdsize=`expr $ISIZE \* 1024`
93 echo "Ramdisk size is $rdsize"
95 echo "Making isolinux.cfg"
96 cat >cdtree/boot/isolinux/isolinux.cfg <<END_OF_DATA
107 append ramdisk_size=$rdsize initrd=initrd.img
113 # we are done with the RAM disk image, delete it
116 echo "Initial RAM disk initrd.img is built."