Skip to content

Instantly share code, notes, and snippets.

@parth-choudhary
Created January 7, 2019 10:29
Show Gist options
  • Save parth-choudhary/d4df82b6d3edcb6ec5d90b7930294a0c to your computer and use it in GitHub Desktop.
Save parth-choudhary/d4df82b6d3edcb6ec5d90b7930294a0c to your computer and use it in GitHub Desktop.
#!/bin/sh
# This script resizes the root partition of the phone, be careful.
set -xe
# needed for https://bugs.launchpad.net/ubuntu/+source/gparted/+bug/373409
echo "Resizing your root partition, this may take some time..."
echo "When done, it will REBOOT the device, make sure you're not losing any work!"
cd /userdata
#create new disk image
dd bs=1M count=6000 if=/dev/zero of=system2.img
#this may take a while, put the kettle on
#mount it as a loopback device
losetup -f --show system2.img
#copy from existing loopback to current one
dd if=/dev/loop0 of=/dev/loop2
# then resize the file system on our new device. This may give a warning, accept it
e2fsck -f /dev/loop2 || true
resize2fs -f /dev/loop2
#now swap over our new image with the old one
mv system.img system.old
mv system2.img system.img
reboot
#enjoy your new / space
df -h
#clear up old files
rm /userdata/system.old
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment