Grow partition on raspberry pi - ashBabu/Utilities GitHub Wiki

Check the layout first

lsblk
sudo parted /dev/mmcblk0 print free

Confirm two things: mmcblk0p2 is the last partition on the card, and there is free space listed after it. If something else sits after p2, the steps below would be unsafe.

Grow the partition

sudo apt install cloud-guest-utils
sudo growpart /dev/mmcblk0 2

Note The space between the device and the number 2. growpart is safe to run while the partition is mounted.

If you would rather not install a package, parted works too:

  • sudo parted /dev/mmcblk0 resizepart 2 100%

It will warn that the partition is in use. Answer "Yes" to proceed and "Ignore" if it asks about re-reading the partition table.

Grow the filesystem

sudo resize2fs /dev/mmcblk0p2
df -h