]> git.sur5r.net Git - bacula/rescue/blob - rescue/knoppix/cdrom/makeinitrd
e543af8e08e29a24962c3f87b77504e6bc595fd8
[bacula/rescue] / rescue / knoppix / cdrom / makeinitrd
1 #!/bin/sh
2
3 TOPDIR=`pwd`
4
5 LOOP2=/tmp/bacula_rescue_loop2
6 rm -rf $LOOP2
7 mkdir -p $LOOP2
8
9 # Assume that everything to be loaded into memory with the
10 # RAM disk image (initrd) is is in the roottree directory. 
11
12 echo "Creating the Initial RAM disk image.... "
13
14 # first find out how much space we need. 
15 ISIZE=`du -s -k  roottree/ | awk '{print $1}'`
16
17 # add 2 Meg for extra   
18 ISIZE=`expr $ISIZE + 2048`
19 echo "Initial RAM disk contents will be $ISIZE KB"
20
21 # delete the existing RAM disk image, if there is one
22 rm -f root
23
24 dd if=/dev/zero of=$TOPDIR/root bs=1k count=$ISIZE
25
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
29
30 # associate it with /dev/loop2
31 losetup /dev/loop2 $TOPDIR/root
32
33 # make an ext2 filesystem on it. Set reserve to 0
34 mke2fs -q -m 0 /dev/loop2 $ISIZE
35 if [ $? != 0 ] ; then
36   echo "Build failed."
37   exit 1
38 fi
39
40 # we mount it...
41 mount /dev/loop2 $LOOP2
42 # ... and delete the lost+found directory 
43 rm -rf $LOOP2/lost+found 
44
45 # then we copy the contents of our roottree to this filesystem
46 cp -dpR roottree/* $LOOP2/
47 cprtn=$?
48
49 # and unmount and divorce /dev/loop2
50 umount $LOOP2
51 losetup -d /dev/loop2 
52 rm -rf $LOOP2
53
54 # If above copy failed, bail out
55 if [ $cprtn != 0 ] ; then
56   echo "RAM disk build failed."
57   exit 1
58 fi
59
60 # This is a newer way of creating a ramfs, which we don't use
61 # (cd roottree; find . | cpio --quiet -c -o) >root
62
63 echo "Building initial RAM disk done"
64
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:
67
68 echo "Compressing the RAM disk image.... "
69
70 # delete any existing one
71 rm -f cdtree/boot/isolinux/initrd.img
72
73 # and gzip our RAM disk image and put it in the right place.
74 gzip -9 -c root >cdtree/boot/isolinux/initrd.img
75 if [ $? != 0 ] ; then
76   echo "Build failed"
77   exit 1
78 fi
79
80 rdsize=`expr $ISIZE \* 1024`
81 echo "Ramdisk size is $rdsize"
82
83 echo "Making isolinux.cfg"
84 cat >cdtree/boot/isolinux/isolinux.cfg <<END_OF_DATA
85 default linux
86 prompt 1
87 display boot.msg
88 timeout 300
89 F1 boot.msg
90 F2 options.msg
91 F3 general.msg
92 F4 kernel.msg
93 label linux
94   kernel vmlinuz
95   append ramdisk_size=$rdsize initrd=initrd.img
96 label memtest86
97   kernel memtest
98   append -
99 END_OF_DATA
100
101 # we are done with the RAM disk image, delete it
102 rm -f root
103
104 echo "Initial RAM disk initrd.img is built."