-1

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)?

1
  • 1
    Questions about resizing linux partitions really belong on Unix & Linux; fdisk and resize2fs aren't unique to the Pi or Ubuntu. See also man resize2fs. You can do this in reverse but the filesystem must be unmounted.
    – goldilocks
    Jul 19, 2015 at 12:10

1 Answer 1

2

I think the easiest way is to connect the card to Linux PC and shrink the partition via GParted.

1
  • Well, indeed, this is the (nearly) obvious method. My question was rather talking about reverting the same method or similar, due to the advantages of not needing a second computer. Anyway, your answer is correct. I will, however, give priority to more directs methods. Jul 19, 2015 at 11:59

Not the answer you're looking for? Browse other questions tagged or ask your own question.