ref: cc4ac997a0da6ea60e23ffb5f8c9361a3eebef32
dir: /rc/bin/inst/partdisk/
#!/bin/rc # desc: edit partition tables (e.g., to create a plan 9 partition) # prereq: configfs switch($1){ case go disks=`{ls /dev/sd*/data >[2]/dev/null | sed 's!/dev/(sd.*)/data!\1!'} if(~ $#disks 0) { echo 'No disk devices were found on your system.' echo 'The installation process cannot continue.' exit giveup } echo 'The following disk devices were found.' echo for(i in $disks) { desc=`{cat /dev/$i/ctl | sed 1q | sed 's/inquiry //'} echo $i '-' $desc @{disk/edisk -r /dev/$i/data ||disk/fdisk -r /dev/$i/data} </dev/null >[2]/dev/null | grep -v '^ mbr' echo } okay=no defdisk=$disks(1) if(~ $#disks 1) default=(-d $disks) if not default=() prompt $default 'Disk to partition' $disks disk=$rd 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 'Shall we create a blank EFI partition table (GPT)' echo 'or install traditional DOS partition table (MBR)?' echo prompt 'Install mbr or gpt' mbr gpt switch($rd) { case mbr disk/mbr -m /386/mbr /dev/$disk/data case gpt disk/edisk -bw /dev/$disk/data diskedit=disk/edisk } } echo echo 'This is '$diskedit'; use it to create a Plan 9 partition.' echo 'If there is enough room, a Plan 9 partition will be' echo 'suggested; you can probably just type ''w'' and then ''q''.' echo $diskedit -a /dev/$disk/data $diskedit -p /dev/$disk/data >/dev/$disk/ctl >[2]/dev/null for(i in /dev/sd*/plan9*){ if(test -f $i){ d=`{basename -d $i} disk/prep -p $i >$d/ctl >[2]/dev/null } } case checkdone # we want at least one disk with both an mbr and a plan9 partition mbrandplan9=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(~ $mbrandplan9 0){ partdisk=notdone export partdisk } }