Plan 9 from Bell Labs’s /usr/web/sources/patch/applied/install-restructurised/bootsetup.new

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#!/bin/rc

# desc: create a boot floppy or configure hard disk to boot plan 9
# prereq: copydist

switch($1) {
case go
	echo
	echo 'Initializing Plan 9 FAT configuration 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(! test -f /tmp/plan9.ini) {
		{
			sfs=`{echo $fs | sed 's;/dev;#S;'}
			if(~ $fstype fossil fossil+venti){
				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
			}
			grep -v '(^\[)|menuitem|adisk|bootfile|bootdisk|bootargs|nobootprompt|mouseport|vgasize|monitor|cdboot' /tmp/plan9.orig
			echo 'mouseport='^$mouseport
			echo 'monitor='^$monitor
			echo 'vgasize='^$vgasize
		} >/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

	if(~ $need9fatformat yes){
		log Initializing Plan 9 FAT partition.
		disk/format -r 2 -d -b /386/pbs \
			/dev/$disk/9fat /n/newfs/386/9load
		# silently install pbslba if the partition is way into the disk.
		# it''s our only hope.  only need this for >8.5GB into the disk.
		# but...
		# there are so few non-LBA bioses out
		# there anymore that we'll do this even if we're only 2GB into
		# the disk.  it's just not worth the headaches of dealing with
		# crappy bioses that don't address the whole 8.5GB properly

		9fatoffset=`{grep '^part 9fat ' /dev/$disk/ctl | awk '{print $4}'}
		if(! ~ $#9fatoffset 1) {
			echo 'could not find plan 9 partition.'
			echo 'cannot happen'
			exit bad
		}
		if(test $9fatoffset -gt 2097152)	# 2GB
			disk/format -b /386/pbslba /dev/$disk/9fat

		mount -c /srv/dos /n/9fat /dev/$disk/9fat
	}

	if(! test -f /n/9fat/4e){
		logprog cp /n/newfs/386/9load /n/9fat/9load
		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

		awk -f /bin/inst/mkini.awk >/n/9fat/plan9.ini
		>/n/9fat/4e
	}

	echo
	echo 'There are myriad ways to boot a Plan 9 system.'
	echo 'You can use any of the following.'
	echo '(You can also repeat this task to use more than one).'
	echo
	echo '  floppy - create a boot floppy'
	echo '  plan9  - make the plan 9 disk partition the default for booting'
	echo '  win9x  - add a plan 9 option to windows 9x boot menu'
	echo '  winnt  - add a plan 9 option to windows nt/2000/xp boot manager'
	echo
	echo '(See the documentation for instructions on booting Plan 9 from LILO.)'
	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' floppy plan9 win9x winnt
	
	if(! boot$rd){
		didbootsetup=$oldbootsetup
		export didbootsetup
	}

case checkdone
	xxxfat=(/dev/sd*/9fat)
	if(! isfat $xxxfat(1) || ! ~ $didbootsetup 1){
		bootsetup=ready
		export bootsetup
	}
}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].