diskparts 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/bin/rc
  2. # diskparts [/dev/sd?? ...] - set up any disk partitions
  3. rfork e
  4. if (! test -e /dev/sdctl)
  5. bind -b '#S' /dev
  6. if (~ $#* 0)
  7. *=`{ls -d /dev/sd* | uniq}
  8. bind -a /bin/disk /bin >[2]/dev/null # work with /boot too
  9. # set up any /dev/sd partitions.
  10. # note that really big disks (e.g., aoe devices) may have no mbr
  11. # partition table because the mbr partition table can't cope with large
  12. # block numbers, so we may have to examine the data file with prep if
  13. # there's no plan9 file. beware that `disk/prep -p data' on a disk with
  14. # no plan 9 partition table will delete all extant partitions.
  15. for(disk) {
  16. if(test -f $disk/data && test -f $disk/ctl)
  17. { fdisk -p $disk/data |
  18. grep -v '^delpart ' >$disk/ctl } >[2]/dev/null
  19. if(test -f $disk/plan9)
  20. parts=($disk/plan9*)
  21. if not
  22. parts=($disk/data)
  23. for(part in $parts)
  24. if(test -f $part)
  25. { prep -p $part |
  26. grep -v '^delpart ' >$disk/ctl } >[2]/dev/null
  27. }
  28. sysname=`{cat /dev/sysname}
  29. # set up any fs(3) partitions
  30. if (! test -e /dev/fs/ctl && test -e '#k/fs')
  31. bind -b '#k' /dev
  32. if (~ $#sysname 1 && ! ~ $sysname '' &&
  33. test -r /cfg/$sysname/fsconfig && test -w /dev/fs/ctl)
  34. read -m /cfg/$sysname/fsconfig >/dev/fs/ctl