shithub: riscv

Download patch

ref: 628611fb5c701365c3b2fcbf705448a1af635cc7
parent: 1613fd9f526dc5a5703bbeb1d84e59980db0845e
author: cinap_lenrek <[email protected]>
date: Fri Jun 5 22:00:51 EDT 2015

inst: provide gpt/mbr choice when disk is blank, format esp

--- a/rc/bin/inst/bootplan9
+++ b/rc/bin/inst/bootplan9
@@ -1,5 +1,20 @@
 #!/bin/rc
 
+# look for esp and format it when not already done
+esp=`{ls /dev/$disk/esp >[2]/dev/null}
+if(~ $#esp 1 && ! ~ fstype $esp dos){
+	echo
+	echo 'Here appears to be a unformated EFI system partition:'
+	echo '	' $esp
+	echo
+	prompt 'Initialize FAT on EFI system partition' yes no
+	switch($rd) {
+	case yes
+		# 4k clusters to force FAT32
+		disk/format -d -c 8 -l ESP $esp
+	}
+}
+
 # look for plan9 partition in the DOS partition table (if any)
 p9part=`{disk/fdisk /dev/$disk/data >[2]/dev/null </dev/null | grep PLAN9 | sed 1q | sed 's/ *(p.) .*/\1/'}
 if(~ $#p9part 0){
@@ -13,19 +28,15 @@
 echo 'FreeBSD bootmgr), it is probably safe to continue using'
 echo 'that boot record rather than install the Plan 9 boot record.'
 echo
-prompt 'Install the Plan 9 master boot record' y n 
+prompt 'Install the Plan 9 master boot record' yes no
 switch($rd) {
-case n
-	;
-case y
+case yes
 	disk/mbr -m /386/mbr /dev/$disk/data
 }
 
-prompt 'Mark the Plan 9 partition active' y n
+prompt 'Mark the Plan 9 partition active' yes no
 switch($rd) {
-case n
-	;
-case y
+case yes
 	{ echo 'A '^$p9part; echo w } | disk/fdisk /dev/$disk/data >[2]/dev/null >/dev/null
 	x=$status
 	if(~ $x '' '|'){
--- a/rc/bin/inst/bootsetup
+++ b/rc/bin/inst/bootsetup
@@ -1,6 +1,6 @@
 #!/bin/rc
 
-# desc: create a boot floppy or configure hard disk to boot plan 9
+# desc: configure hard disk to boot plan 9
 # prereq: copydist
 
 fats=()
@@ -73,7 +73,7 @@
 
 	if(~ $need9fatformat yes){
 		log Initializing Plan 9 FAT partition.
-		logprog disk/format -r 2 -d -b /n/newfs/386/pbs $9fat
+		logprog disk/format -r 2 -d -b /n/newfs/386/pbs -l PLAN9 $9fat
 	}
 	if not {
 		log Updating bootsector.
--- a/rc/bin/inst/partdisk
+++ b/rc/bin/inst/partdisk
@@ -32,23 +32,25 @@
 	prompt $default 'Disk to partition' $disks
 	disk=$rd
 
-	if(! ./hasmbr /dev/$disk/data) {
+	diskedit=disk/fdisk
+	if(disk/edisk -p /dev/$disk/data >/dev/null >[2=1])
+		diskedit=disk/edisk
+
+	if(~ $diskedit disk/fdisk && ! ./hasmbr /dev/$disk/data) {
 		echo 'The disk you selected HAS NO master boot record on its first sector.'
 		echo '(Perhaps it is a completely blank disk.)'
-		echo 'You need a master boot record to use the disk.'
-		echo 'Should we install a default master boot record?'
+		echo 'Shall we create a blank EFI partition table (GPT)'
+		echo 'or install traditional DOS partition table (MBR)?'
 		echo
-		prompt 'Install mbr' y n
+		prompt 'Install mbr or gpt' mbr gpt
 		switch($rd) {
-		case y
+		case mbr
 			disk/mbr -m /386/mbr /dev/$disk/data
-			pickdisk=done
+		case gpt
+			disk/edisk -bw /dev/$disk/data
+			diskedit=disk/edisk
 		}
 	}
-
-	diskedit=disk/fdisk
-	if(disk/edisk -p /dev/$disk/data >/dev/null >[2=1])
-		diskedit=disk/edisk	
 
 	echo
 	echo 'This is '$diskedit'; use it to create a Plan 9 partition.'