5 mkdir -p /mnt/loop1 /mnt/loop2
8 # we need to set aside a few loop devices. I chose (in reverse order of their appearance)
9 # -- loop1 for the boot image
10 # -- loop2 for the RAM disk image
11 # since the loop1 choice is reflected in the lilo.loopfix file,
12 # you should not change that (or you need to change the file).
13 # I had used loop0 first, but I found that this is used by the Samba daemon.
14 # Also, I assume that the mount points are /mnt/loop{1,2}.
15 # In principle we could do with one, but it comes in handy to be able to
16 # leave one mounted, so I took two different ones.
18 # Assume that everything to be loaded into memory with the
19 # RAM disk image (initrd) is is in the roottree directory.
21 echo "Creating the Initial RAM disk image.... "
23 # first find out how much space we need.
24 ISIZE=`du -s -k roottree/ | awk '{print $1}'`
27 ISIZE=`expr $ISIZE + 2048`
28 echo "Initial RAM disk contents will be $ISIZE KB"
30 # delete the existing RAM disk image, if there is one
33 dd if=/dev/zero of=$TOPDIR/root bs=1k count=$ISIZE
35 umount /mnt/loop2 2>/dev/null >/dev/null
36 losetup -d /dev/loop2 2>/dev/null >/dev/null
38 # associate it with /dev/loop2
39 losetup /dev/loop2 $TOPDIR/root
41 # make an ext2 filesystem on it. Set reserve to 0
42 mke2fs -q -m 0 /dev/loop2 $ISIZE
49 mount /dev/loop2 /mnt/loop2
51 # ... and delete the lost+found directory
52 rm -rf /mnt/loop2/lost+found
54 # then we copy the contents of our roottree to this filesystem
55 cp -dpR roottree/* /mnt/loop2/
57 echo "RAM disk build failed."
61 # and unmount and divorce /dev/loop2
65 # (cd roottree; find . | cpio --quiet -c -o) >root
67 echo "Building initial RAM disk done"
69 # Now we have the image of the RAM disk in $TOPDIR/loopfiles/root. We
70 # compress this one and write the compressed image to the boot tree:
72 echo "Compressing the RAM disk image.... "
74 # delete any existing one
75 rm -f cdtree/boot/isolinux/initrd.img
77 # and gzip our RAM disk image and put it in the right place.
78 gzip -9 -c root >cdtree/boot/isolinux/initrd.img
84 rdsize=`expr $ISIZE \* 1024`
85 echo "Ramdisk size is $rdsize"
87 echo "Making isolinux.cfg"
88 cat >cdtree/boot/isolinux/isolinux.cfg <<END_OF_DATA
99 append ramdisk_size=$rdsize initrd=initrd.img
105 # we are done with the RAM disk image, delete it
108 echo "Initial RAM disk initrd.img is built."