summaryrefslogtreecommitdiff
path: root/rc/bin/inst/partdisk
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@localhost>2011-04-12 15:53:55 +0000
committercinap_lenrek <cinap_lenrek@localhost>2011-04-12 15:53:55 +0000
commit67e93d6a0a4f15192638e131413b9d64c4269c76 (patch)
tree88fd1d17c4be283683a96ced44159e3ce6b6f2f7 /rc/bin/inst/partdisk
parent7208d528bd42f981f2535403f72e4c0d7d8df643 (diff)
downloadplan9front-67e93d6a0a4f15192638e131413b9d64c4269c76.tar.xz
updating cwfs and moving installer in /rc/bin
Diffstat (limited to 'rc/bin/inst/partdisk')
-rwxr-xr-xrc/bin/inst/partdisk73
1 files changed, 73 insertions, 0 deletions
diff --git a/rc/bin/inst/partdisk b/rc/bin/inst/partdisk
new file mode 100755
index 000000000..430d45f3f
--- /dev/null
+++ b/rc/bin/inst/partdisk
@@ -0,0 +1,73 @@
+#!/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
+ 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
+ }
+}