3 # mkboot 2.0 - make boot floppy, make root device bootable, etc.
6 trap 'e=$?; rm -f /tmp/mkb.$$; exit $e' 0 2
8 mdec
=/usr
/mdec
# bootstraps
12 1:bootable |
1:hdboot |
[12]:fdboot
)
13 action
=$1 dev
=$2 size
=$3
15 *) echo "Usage: $0 [bootable | hdboot | fdboot [device]]" >&2
19 # Get the device table.
22 # The real root device may be the RAM disk.
23 realroot
=`printroot -r`
25 # If it's an initial fstab, pretend root is real root
26 if [ $root = "/dev/ROOT" ]
32 # We need the root device.
34 if [ $realroot = $root ]
38 umount
$root 2>/dev
/null
39 mount
$root /mnt ||
exit
46 # Install the boot monitor on the root device and make it bootable.
47 install -cs -m 644 $mdec/boot
$rootdir/boot
/boot ||
exit
49 installboot
-device $root $mdec/bootblock
/boot
/boot ||
exit
50 test $realroot != $root && umount
$root
53 # Install a new image on the root device.
54 if [ ! -d $rootdir/boot
/image
]
56 # /boot/image is not yet a directory! Fix it.
58 "exec mv $rootdir/boot/image /M"
59 install -d $rootdir/boot
/image
61 "exec mv $rootdir/M $rootdir/boot/image/`uname -r`.`uname -v`"
64 sh tell_config OS_RELEASE . OS_VERSION
>/tmp
/mkb.$$
65 version
=`sed 's/[" ]//g;/^$/d' </tmp/mkb.$$`
67 revision
=`cat revision 2>/dev/null`
71 else rrevision
=r
$revision
76 target
="${version}r${revision}"
82 elif [ -f $rootdir/boot
/image
/$target ]
84 if [ $rootdir/boot
/image
/$target -newer image
]
86 echo "$root:/boot/image/$target is up to date"
87 test $realroot != $root && umount
$root
90 revision
=`expr $revision + 1`
93 target
="${version}${rrevision}"
95 set -- `ls -t $rootdir/boot/image`
99 # Not much there, do not remove a thing.
102 # Remove the third-newest image in /boot/image, but
103 # only if there's an older one (which is kept).
104 echo "rm $root:/boot/image/$3"
105 rm -f "$rootdir/boot/image/$3"
108 # Install the new image.
109 echo "install image $root:/boot/image/$target"
110 install -o root
-m 600 image
$rootdir/boot
/image
/$target ||
exit
112 # Save the revision number.
113 test "$revision" != "$oldrev" && echo $revision >revision
115 test $realroot != $root && umount
$root
119 # fdboot: Make a boot floppy.
124 "Finish the name of the floppy device to write (by default 'fd0'): /dev/";
135 # Make a file system.
136 umount
$dev 2>/dev
/null
137 if mkfs
-B 1024 -i 512 $dev
140 echo "mkfs of $dev failed."
144 # Install /dev, /boot/boot and /boot/image.
145 mount
$dev /mnt ||
exit
146 mkdir
-p /mnt
/boot
/image ||
exit
147 cpdir
/dev
/mnt
/dev ||
exit
148 cp -p $mdec/boot
/mnt
/boot
/boot ||
exit
149 cp -p image
/mnt
/boot
/image
/ ||
exit
152 # Make bootable and copy the boot parameters.
153 installboot
-d $dev $mdec/bootblock
/boot
/boot ||
exit
156 then echo "Using floppy boot parameters from file $pfile."
157 edparams
$dev "`cat $pfile`" ||
exit
158 else echo "Copying floppy boot parameters from $root."
159 dd if=$root of
=$dev skip
=1 seek
=1 count
=1 conv
=silent ||
exit
161 edparams
$dev 'main(){delay 2000;boot}; save' ||
exit
162 echo "Test kernel installed on $dev"