I prefer to see graphical interface while dealing with partition. We’ll need another RPi to resize the target MMC for another RPi.

What we need

  • MMC (pre-booted on main RPi)
  • RPi with GUI
  • USB MMC reader

GParted

Install GParted

From the command line use

sudo apt update && sudo apt upgrade -y
sudo apt install gparted -y

Run GParted

Next step will require us to vnc into RPi with GUI

GParted can be found in Pi > System Tools > GParted

Before inserting “target” MMC, we’ll see what is the name of the system disk that we are booting from (e.g. mmcblk0p1, mmcblk0p2).

Choose target MMC

Insert target MMC and refresh.

From the selection at top right, drop down to target device selection (e.g. /dev/sdb).

Run the following command to see if the target card is mounted

lsblk

If partition is mounted, right click anywhere on the main panel and select unmount first as we are not able to do any partition adjustment when disk is mounted.

Resizing target

Right click on the rootfs ext4 partition of target card and select check, then green tick button. This step is not necessary but will see if there are issues that will likely cause the resize to fail.

Next, we can right click on the partition above and select resize then enter the size that we want to shrink to (e.g. 8192MB). Click Resize/Move button to continue.

Click on the green tick button to commit the changes.

Create new partition

Click on the last unallocated partition and choose New option.

Keep default options and name the label.

Click on the green tick button to commit the changes.

Parted

Example below:

  • Remove /dev/sdb3 partition
  • Extend /dev/sdb2 partition from whatever is being left from /dev/sdb3
# Start parted on storage device
sudo parted /dev/sdb

# Get the number of sdb3
(parted) print free

# In our case, sdb3 is located at Number 3
# Remove partition sdb3
(parted) rm 3

# Check if partition already removed
(parted) print free

# Resize partition for sdb2
(parted) resizepart
Partition number? 2
End? [8863MB]? 31GB # or the number lower than End of the last Free space

# Check if partition already allocated
(parted) print free

# Exit parted
(parted) quit

# Extend "usable" partition
sudo resize2fs /dev/sdb2

# Check if resize completed
lsblk -f # Check on FSUSE% column

Last modified: 7 February 2022