1
0

bootplan9 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/bin/rc
  2. first=`{ls -p '#S' | sed 1q}
  3. if(! ~ $first $disk) {
  4. echo 'warning: The plan 9 partition is not on the boot disk,'
  5. echo 'so making it the active partition will have no effect.'
  6. }
  7. p9offset=`{grep '^part 9fat ' /dev/$disk/ctl |awk '{print $3}'}
  8. if(! ~ $#p9offset 1) {
  9. echo 'could not find plan 9 partition.'
  10. echo 'cannot happen'
  11. exit bad
  12. }
  13. if(test $p9offset -gt 4128695) { # 65536 * 63 - 10
  14. echo
  15. echo 'Your Plan 9 partition is more than 2GB into your disk,'
  16. echo 'and the master boot records used by Windows 9x/ME'
  17. echo 'cannot access it (and thus cannot boot it).'
  18. echo
  19. echo 'You can install the Plan 9 master boot record, which can load'
  20. echo 'partitions far into the disk.'
  21. echo
  22. }
  23. echo 'If you use the Windows NT/2000/XP master boot record'
  24. echo 'or a master boot record from a Unix clone (e.g., LILO or'
  25. echo 'FreeBSD bootmgr), it is probably safe to continue using'
  26. echo 'that boot record rather than install the Plan 9 boot record.'
  27. echo
  28. prompt 'Install the Plan 9 master boot record' y n
  29. switch($rd) {
  30. case n
  31. ;
  32. case y
  33. disk/mbr -m /386/mbr /dev/$disk/data
  34. }
  35. log Setting Plan 9 partition active.
  36. p9part=`{disk/fdisk /dev/$disk/data >[2]/dev/null </dev/null |
  37. grep PLAN9 | sed 1q | sed 's/ *(p.) .*/\1/'}
  38. if(~ $#p9part 0){
  39. echo 'You have no Plan 9 partitions (How could this happen?)' >[1=2]
  40. exit 'no plan 9 partition found'
  41. }
  42. p9part=$p9part(1)
  43. { echo 'A '^$p9part; echo w } | disk/fdisk /dev/$disk/data >[2]/dev/null >/dev/null
  44. x=$status
  45. if(~ $x '' '|'){
  46. echo
  47. echo 'The Plan 9 partition is now marked as active.'
  48. exit ''
  49. }
  50. exit $x