#!/bin/rc # desc: edit partition tables (e.g., to create a plan 9 partition) # prereq: 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 echo e | disk/fdisk -r /dev/$i/data >[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 if(! 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 prompt 'Install mbr' y n switch($rd) { case y disk/mbr -m /386/mbr /dev/$disk/data pickdisk=done } } echo echo 'This is disk/fdisk; 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 disk/fdisk -a /dev/$disk/data disk/fdisk -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 } }