1. #!/bin/bash


  2. cylinders=$(fdisk -l |grep cylinders | awk '{print $8}' | head -n 1)

  3. real_cylind=$(($cylinders - 1))

  4. echo $cylinders

  5. echo $real_cylind


  6. fdisk /dev/sda <<EOF

  7. n

  8. p

  9. 1

  10. 2048

  11. 10487807

  12. a

  13. 1

  14. n

  15. p

  16. 2

  17. 10487808

  18. 77596671

  19. t

  20. 2

  21. 82

  22. n

  23. p

  24. 3

  25. 77596672

  26. $[real_cylind]

  27. w

  28. EOF