From d76c9642e0985b6791ed723234a22ec383102aff Mon Sep 17 00:00:00 2001 From: Jacob Moody Date: Wed, 22 May 2024 01:49:46 +0000 Subject: [PATCH] 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. --- rc/bin/inst/bootsetup | 2 +- rc/bin/inst/partdisk | 12 +++++++----- rc/bin/inst/prepdisk | 24 +++++++++++++++++++++--- 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/rc/bin/inst/bootsetup b/rc/bin/inst/bootsetup index c1de3dce2..bce607476 100755 --- 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) } diff --git a/rc/bin/inst/partdisk b/rc/bin/inst/partdisk index bbe33fbbf..ccb0489c4 100755 --- a/rc/bin/inst/partdisk +++ b/rc/bin/inst/partdisk @@ -67,14 +67,16 @@ case go } 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 } diff --git a/rc/bin/inst/prepdisk b/rc/bin/inst/prepdisk index c3c08cf78..80fbf2bfc 100755 --- 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 @@ case go 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 @@ case go 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)