Advertisement
Guest User

resize.sh

a guest
Nov 10th, 2014
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.62 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. fdisk_first() {
  4.         p2_start=`fdisk -l /dev/mmcblk0 | grep mmcblk0p2 | awk '{print $2}'`
  5.         echo "Found the start point of mmcblk0p2: $p2_start"
  6.         fdisk /dev/mmcblk0 << __EOF__ >> /dev/null
  7. d
  8. 2
  9. n
  10. p
  11. 2
  12. $p2_start
  13.  
  14. p
  15. w
  16. __EOF__
  17.  
  18.         sync
  19.         touch /root/.resize
  20.         echo "Ok, Partition resized, please reboot now"
  21.         echo "Once the reboot is completed please run this script again"
  22. }
  23.  
  24. resize_fs() {
  25.     echo "Activating the new size"
  26.     resize2fs /dev/mmcblk0p2 >> /dev/null
  27.     echo "Done!"
  28.     echo "Enjoy your new space!"
  29.     rm -rf /root/.resize
  30. }
  31.  
  32.  
  33. if [ -f /root/.resize ]; then
  34.     resize_fs
  35. else
  36.     fdisk_first
  37. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement