# desc: create a boot floppy or configure hard disk to boot plan 9
# prereq: copydist
+fats=()
+for(i in /dev/sd*/9fat){
+ if(test -f $i)
+ fats=($fats $i)
+}
+
switch($1) {
+case checkdone checkready
+ if(~ $#fats 0 || ~ $#9fat 1 && ~ `{fstype $9fat} dos && ~ $didbootsetup 1)
+ bootsetup=done
+ if not
+ bootsetup=ready
+ export bootsetup
+
case go
echo
- echo 'Initializing Plan 9 FAT configuration partition (9fat)'
+ echo 'Setup Plan 9 FAT boot partition (9fat)'
echo
-
- fat=(/dev/sd*/9fat)
- fat=$fat(1)
- disk=`{echo $fat | sed 's:/dev/::;s:/9fat::'}
- bootfs=`{echo $fs | sed 's:/dev/(sd..)/(.*):\1!\2:'}
- bootfat=`{echo $fs | sed 's:/dev/(sd..)/(.*):\1!9fat:'}
- if(! test -f /dev/$disk/9fat) {
- echo 'You have no 9fat partition. Can''t setup booting.'
- exit
- }
+
+ if(~ $#fats 1)
+ default=(-d $fats)
+ if not
+ default=()
+ prompt $default 'Plan 9 FAT partition' $fats
+ 9fat=$rd
+ export 9fat
if(! test -f /tmp/plan9.ini) {
- {
- sfs=`{echo $fs | sed 's;/dev;#S;'}
- if(~ $fstype fossil cwfs){
- echo bootfile'='$bootfat!9pcf
- echo 'bootargs=local!'^$sfs
- echo 'bootdisk=local!'^$sfs
- }
- if not {
- echo bootfile'='$bootfs!/386/9pcdisk
- echo 'bootdisk=local!'^$sfs
- }
- if(~ $fstype fossil+venti){
- venti=`{echo $ventiarena | sed 's;/dev;#S;'}
- echo venti'='^$venti
- }
- # sort -u avoids dups which could otherwise trigger
- # pointless boot menus.
- grep -v '(^\[)|menuitem|adisk|bootfile|bootdisk|bootargs|nobootprompt|mouseport|vgasize|monitor|cdboot' /tmp/plan9.orig |
- sort -u
+ bootfile=9pcf
+ @{
+ echo 'bootfile='^$bootfile
+ echo 'bootargs=local!'^$fs' '$"fsflags
+ if(~ $#nvram 1)
+ echo 'nvram='^$nvram
echo 'mouseport='^$mouseport
echo 'monitor='^$monitor
echo 'vgasize='^$vgasize
+ cd '#ec'
+ for(i in *){
+ echo -n $"i'='
+ cat $i
+ echo
+ } | grep -v '(apm0|e820|bootfile|bootargs|nvram|mouseport|monitor|vgasize|cdboot)'
} >/tmp/plan9.ini
}
- if(! test -f /tmp/plan9ini.bak)
- cp /tmp/plan9.ini /tmp/plan9ini.bak
- need9fatformat=no
- if(! isfat /dev/$disk/9fat)
- need9fatformat=yes
- if not if(! mount -c /srv/dos /n/9fat /dev/$disk/9fat >[2]/dev/null)
- need9fatformat=yes
- if not if(! test -f /n/9fat/plan9.ini)
- need9fatformat=yes
+ # clean state
+ rm -f /tmp/oldplan9.ini /tmp/pbs.bak
+ unmount /n/9fat >[2]/dev/null
+
+ if(! test -f /srv/dos)
+ dossrv
+
+ need9fatformat=yes
+ if(~ `{fstype $9fat} dos){
+ if(mount /srv/dos /n/9fat $9fat >[2]/dev/null){
+ if(cp /n/9fat/plan9.ini /tmp/oldplan9.ini >[2]/dev/null)
+ need9fatformat=no
+ unmount /n/9fat >[2]/dev/null
+
+ # make sure dossrv is gone
+ sleep 1
+ }
+ }
+
+ # always make backup of old bootsector
+ logprog dd -bs 512 -count 1 -if $9fat -of /tmp/pbs.bak
if(~ $need9fatformat yes){
log Initializing Plan 9 FAT partition.
- disk/format -r 2 -d -b /386/pbs \
- /dev/$disk/9fat /n/newfs/386/9bootfat
- mount -c /srv/dos /n/9fat /dev/$disk/9fat
+ logprog disk/format -r 2 -d -b /n/newfs/386/pbs $9fat
+ }
+ if not {
+ log Updating bootsector.
+ logprog disk/format -b /n/newfs/386/pbs $9fat
}
- if(! test -f /n/9fat/4e){
- logprog cp /n/newfs/386/9bootfat /n/9fat/9bootfat
- logprog cp /n/newfs/386/9pcf /n/9fat/9pcf
- if(test -f /n/9fat/plan9.ini && ! test -f /n/9fat/plan9-3e.ini)
- logprog mv /n/9fat/plan9.ini /n/9fat/plan9-3e.ini
- if(test -f /n/9fat/9pcdisk && ! test -f /n/9fat/9pc3e)
- logprog mv /n/9fat/9pcdisk /n/9fat/9pc3e
+ logprog mount -c /srv/dos /n/9fat $9fat
- awk -f /bin/inst/mkini.awk >/n/9fat/plan9.ini
- >/n/9fat/4e
- }
+ logprog rm -f /n/9fat/^(9bootfat plan9.ini 9pcf)
- echo
- echo 'There are myriad ways to boot a Plan 9 system.'
- echo 'You can use any of the following.'
- echo
- echo ' plan9 - make the plan 9 disk partition the default for booting'
- echo ' winnt - add a plan 9 option to windows nt/2000/xp boot manager'
- echo
- echo 'If you are upgrading an extant third edition installation and booting'
- echo 'from something other than a floppy, you needn''t run anything here.'
- echo 'Just type ctl-d.'
-
- oldbootsetup=$didbootsetup
- didbootsetup=1
- export didbootsetup
- prompt 'Enable boot method' plan9 winnt
-
- if(! boot$rd){
- didbootsetup=$oldbootsetup
- export didbootsetup
- }
+ logprog cp /n/newfs/386/9bootfat /n/9fat/9bootfat
+ # make file continous on disk
+ logprog chmod +al /n/9fat/9bootfat
-case checkdone
- xxxfat=(/dev/sd*/9fat)
- if(! isfat $xxxfat(1) || ! ~ $didbootsetup 1){
- bootsetup=ready
- export bootsetup
+ logprog cp /tmp/plan9.ini /n/9fat/plan9.ini
+ logprog cp /n/newfs/386/9pcf /n/9fat/9pcf
+
+ # copy in backups
+ if(test -f /tmp/oldplan9.ini)
+ logprog cp /tmp/oldplan9.ini /n/9fat
+ if(test -f /tmp/pbs.bak)
+ logprog cp /tmp/pbs.bak /n/9fat
+
+ logprog unmount /n/9fat
+
+ disk=`{basename `{basename -d $9fat}}
+ if(./bootplan9){
+ didbootsetup=1
+ export didbootsetup
}
}