shithub: front

Download patch

ref: d76c9642e0985b6791ed723234a22ec383102aff
parent: 5b13dcf68d9ed5113832229d3d0d7e8484a0e946
author: Jacob Moody <moody@posixcafe.org>
date: Tue May 21 21:49:46 EDT 2024

inst: add option to use esp as 9fat

Currently we place efi boot binaries on to the 9fat and hope that the
firmware will look in more places than just the esp.  Based on user
reports we've found that it is quite common for firmware to only
search the esp.

--- a/rc/bin/inst/bootsetup
+++ b/rc/bin/inst/bootsetup
@@ -4,7 +4,7 @@
 # prereq: copydist
 
 fats=()
-for(i in /dev/sd*/9fat){
+for(i in (/dev/sd*/9fat /dev/sd*/esp)){
 	if(test -f $i)
 		fats=($fats $i)
 }
--- a/rc/bin/inst/partdisk
+++ b/rc/bin/inst/partdisk
@@ -67,14 +67,16 @@
 	}
 
 case checkdone
-	# we want at least one disk with both an mbr and a plan9 partition
-	mbrandplan9=0
+	# we want at least one disk that is both bootable and contains a Plan 9 partition
+	bootandplan9=0
 	disks=`{ls /dev/sd*/plan9 >[2]/dev/null | sed 's!/dev/(sd.*)/plan9!\1!'}
 	for(disk in $disks) {
-		if(./hasmbr /dev/$disk/data)
-			mbrandplan9=1
+		if(test -f /dev/$disk/esp)
+			bootandplan9=1
+		if not if(./hasmbr /dev/$disk/data)
+			bootandplan9=1
 	}
-	if(~ $mbrandplan9 0){
+	if(~ $bootandplan9 0){
 		partdisk=notdone
 		export partdisk
 	}
--- a/rc/bin/inst/prepdisk
+++ b/rc/bin/inst/prepdisk
@@ -3,13 +3,20 @@
 # desc: subdivide plan 9 disk partition
 # prereq: partdisk
 
+useesp=no
+
 fn autotype {
+	if(~ $useesp no)
+		parts=(9fat)
+	if not
+		parts=()
 	switch($fstype){
 	case cwfs cwfs64 cwfs64x
-		echo -a 9fat -a nvram -a fscache -a fsworm -a other
+		parts=($parts nvram fscache fsworm other)
 	case hjfs gefs
-		echo -a 9fat -a nvram -a fs
+		parts=($parts nvram fs)
 	}
+	echo '-a '^$parts
 }
 
 switch($1) {
@@ -36,6 +43,17 @@
 	prompt $default 'Plan 9 partition to subdivide' $disks
 	disk=$rd
 
+	if(ls `{basename -d $disk}^/esp >[2]/dev/null){
+		echo
+		echo 'By default 9front places its boot materials on its own 9fat partition.'
+		echo 'This requires the firmware be capable of booting from fat partitions other than the esp.'
+		echo 'You can also place all boot materials directly on the esp instead.'
+		echo 'This option works with a larger set of machines, but may disrupt existing configurations.'
+		echo
+		prompt -d no 'Use esp as 9fat?' no yes
+		useesp=$rd
+	}
+
 	echo 'This is disk/prep; use it to subdivide the Plan 9 partition.'
 	echo 'If it is not yet subdivided, a sensible layout will be suggested;'
 	echo 'you can probably just type ''w'' and then ''q''.'
@@ -44,7 +62,7 @@
 	disk/prep -p $disk >`{basename -d $disk}^/ctl >[2]/dev/null
 
 case checkdone
-	disks=(/dev/sd*/9fat)
+	disks=(/dev/sd*/nvram)
 	if(! test -f $disks(1))
 		prepdisk=ready
 	if(! ~ $prepdisk ready)
--