5 # mkdir -p /mnt/loop1 /mnt/loop2
7 # we need to set aside a few loop devices. I chose (in reverse order of their appearance)
8 # -- loop1 for the boot image
9 # -- loop2 for the RAM disk image
10 # since the loop1 choice is reflected in the lilo.loopfix file,
11 # you should not change that (or you need to change the file).
12 # I had used loop0 first, but I found that this is used by the Samba daemon.
13 # Also, I assume that the mount points are /mnt/loop{1,2}.
14 # In principle we could do with one, but it comes in handy to be able to
15 # leave one mounted, so I took two different ones.
17 # Assume that everything to be loaded into memory with the
18 # RAM disk image (initrd) is is in the roottree directory.
20 echo "Creating the Initial RAM disk image.... "
22 # first find out how much space we need.
23 ISIZE=`du -s -k roottree/ | awk '{print $1}'`
26 ISIZE=`expr $ISIZE + 2048`
27 echo "Initial RAM disk contents will be $ISIZE KB"
29 # delete the existing RAM disk image, if there is one
32 # dd if=/dev/zero of=$TOPDIR/root bs=1k count=$ISIZE
34 # umount /mnt/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
42 # if [ $? != 0 ] ; then
43 # echo "Build failed."
48 # mount /dev/loop2 /mnt/loop2
50 # # ... and delete the lost+found directory
51 # rm -rf /mnt/loop2/lost+found
53 # # then we copy the contents of our roottree to this filesystem
54 # cp -dpR roottree/* /mnt/loop2/
55 # if [ $? != 0 ] ; then
56 # echo "RAM disk build failed."
60 # # and unmount and divorce /dev/loop2
62 # losetup -d /dev/loop2
64 (cd roottree; find . | cpio --quiet -c -o) >root
66 echo "Building initial RAM disk done"
68 # Now we have the image of the RAM disk in $TOPDIR/loopfiles/root. We
69 # compress this one and write the compressed image to the boot tree:
71 echo "Compressing the RAM disk image.... "
73 # delete any existing one
74 rm -f cdtree/boot/isolinux/initrd.img
76 # and gzip our RAM disk image and put it in the right place.
77 # gzip -9 -c root >cdtree/boot/isolinux/initrd.img
78 gzip -9 < 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."