ExpandExternalInstall.sh 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #!/bin/bash
  2. #Expand PrawnOS to fill the entire external device
  3. # This file is part of PrawnOS (http://www.prawnos.com)
  4. # Copyright (c) 2018 Hal Emmerich <hal@halemmerich.com>
  5. # PrawnOS is free software: you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License version 2
  7. # as published by the Free Software Foundation.
  8. # PrawnOS is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. # You should have received a copy of the GNU General Public License
  13. # along with PrawnOS. If not, see <https://www.gnu.org/licenses/>.
  14. while true; do
  15. echo "This script will expand PrawnOS to fill the entire external"
  16. echo " storage device it is booted from"
  17. echo "If installing to a USB flash drive, make sure only one USB storage device is plugged in"
  18. read -p "install to: internal external (S)D, external (U)SB Storage: " ESU
  19. case $ESU in
  20. [Ss]* ) TARGET=SD; break;;
  21. [Uu]* ) TARGET=USB; break;;
  22. * ) echo "Please answer S or U";;
  23. esac
  24. done
  25. if [ "$TARGET" = "USB" ]
  26. then
  27. #Make the boot partition fille the whole drive
  28. #Delete the partition
  29. sgdisk -d 2 /dev/sda
  30. #Make new partition map entry, with full size
  31. sgdisk -N 2 /dev/sda
  32. #Set the type to "data"
  33. sgdisk -t 2:0700 /dev/sda
  34. #Name is "properly" - Probably not required, but looks nice
  35. sgdisk -c 2:Root /dev/sda
  36. #Reload the partition mapping
  37. partprobe /dev/sda
  38. #Force the filesystem to fill the new partition
  39. resize2fs -f /dev/sda2
  40. fi
  41. if [ "$TARGET" = "SD" ]
  42. then
  43. #Make the boot partition fille the whole drive
  44. #Delete the partition
  45. sgdisk -d 2 /dev/mmcblk0
  46. #Make new partition map entry, with full size
  47. sgdisk -N 2 /dev/mmcblk0
  48. #Set the type to "data"
  49. sgdisk -t 2:0700 /dev/mmcblk0
  50. #Name is "properly" - Probably not required, but looks nice
  51. sgdisk -c 2:Root /dev/mmcblk0
  52. #Reload the partition mapping
  53. partprobe /dev/mmcblk0
  54. #Force the filesystem to fill the new partition
  55. resize2fs -f /dev/mmcblk0p2
  56. fi