1
0

diskparts 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/cmd/rc
  2. rfork e
  3. # note that really big disks (e.g., aoe devices) may have no mbr
  4. # partition table because the mbr partition table can't cope with large
  5. # block numbers, so we may have to examine the data file with prep if
  6. # there's no plan9 file. beware that `disk/prep -p data' on a disk with
  7. # no plan 9 partition table will delete all extant partitions.
  8. fn setup {
  9. if(test -f $1/data && test -f $1/ctl)
  10. {@{disk/fdisk -p $1/data} |
  11. grep -v '^delpart ' >$1/ctl } >[2]/dev/null
  12. if(test -f $1/plan9)
  13. parts=($1/plan9*)
  14. if not
  15. parts=($1/data)
  16. for(part in $parts)
  17. if(test -f $part)
  18. { disk/prep -p $part |
  19. grep -v '^delpart ' >$1/ctl } >[2]/dev/null
  20. }
  21. if(~ $#* 0){
  22. # set up any disk partitions
  23. if (! test -e /dev/sdctl)
  24. bind -b '#S' /dev
  25. for(disk in /dev/sd*) {
  26. setup $disk
  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. awk '{print $0; fflush}' /cfg/$sysname/fsconfig >/dev/fs/ctl
  35. }
  36. if not {
  37. for(disk) {
  38. setup $disk
  39. }
  40. }