Extracted from the instructions from the original docs for installing Ubuntu on RaspBerry Pi 2:
There are no Raspbian-specific utilities included, specifically no automatic root resizer. However, it's not hard to do manually. Once booted
$ sudo fdisk /dev/mmcblk0
Delete the second partition (d, 2), then re-create it using the defaults (n, p, 2, enter, enter), then write and exit (w). Reboot the system, then:
$ sudo resize2fs /dev/mmcblk0p2
By using this method, the 2GB root partition extracted from the .img Ubuntu file can be expanded to the full size of my, say, 32GB SD card.
Is it possible to revert this step to shrink the, say, 32GB root filesystem size, to something smaller like, say, 4GB (assuming, of course, that filesystem has no more than that 4GB data full)?
fdisk
andresize2fs
aren't unique to the Pi or Ubuntu. See alsoman resize2fs
. You can do this in reverse but the filesystem must be unmounted. – goldilocks Jul 19 '15 at 12:10