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 |
[12]:cdfdboot
)
15 *) echo "Usage: $0 [bootable | hdboot | cdfdboot | fdboot [device]] | cdfdboot [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"
166 # cdfdboot: Make a boot floppy image to go on a CD for booting from.
169 ramdisk
`expr 1440 \* 1024` 2>/dev
/null
172 umount
$dev 2>/dev
/null
173 if mkfs
-B 1024 -b 1440 -i 512 $dev ||
exit 1
176 echo "mkfs of $dev failed."
180 # Install /dev, /boot
181 mount
$dev /mnt ||
exit 1
184 mkdir
/mnt
/boot
/image
185 ( cd /mnt
/dev
&& sh
/usr
/src
/commands
/scripts
/MAKEDEV.sh std
)
186 cp -p image
/mnt
/boot
/image ||
exit 1
187 cp -p ..
/boot
/boot
/mnt
/boot
/boot ||
exit 1
188 umount
$dev ||
exit 1
189 installboot
-d $dev ..
/boot
/bootblock boot
/boot ||
exit 1
200 bootbig(1, Regular MINIX 3) { unset image; boot }
201 leader() { echo \n--- Welcome to MINIX 3. This is the boot monitor. ---\n\nChoose an option from the menu or press ESC if you need to do anything special.\nOtherwise I will boot with my defaults in 10 seconds.\n\n };
202 main(){trap 10000 boot; menu; };
206 dd if=$dev of
=cdfdimage bs
=8192 count
=180