0

Given the disk space on my Raspberry Pi was too small, I moved from a 32 GB SD card to a 128 GB SD card on my Raspberry Pi 5. Therefore, I cloned the old card to the new one using:

sudo dd if=/dev/mmcblk0 of=/dev/sda status=progress

However, I checked afterwards the partition sizes and saw that only about 32 out of 128 GB are usable. Here the output of lsblk:

auronzo@raspberry:~ $ sudo lsblk -m
NAME          SIZE OWNER GROUP MODE
mmcblk0     119.1G root  disk  brw-rw----
|-mmcblk0p1   512M root  disk  brw-rw----
`-mmcblk0p2  29.2G root  disk  brw-rw----

How can I increase the partition mmcblk0p2 (ideally to the max. size) without moving the content around?

Giacomo1968
  • 58,727

1 Answers1

3

Same way you would do this on most standard Linux distributions.

The first step is to back the system up (it should be considered a risky operation). Then using fdisk or similar delete the second partition and recreate it with the full available size, making sure the start sector and partition type is the same.

Restart the Raspberry Pi so it identifies the new partition (might not be required).

Expand the filesystem using a command like

resize2fs /dev/mmcblk0p2

Might be resize4fs instead, depending on what Pi comes with. (ext4 is a less ancient version of the ext2 filesystem more features, but either command will work - its whatever comes with your distro - its the same tool).

davidgo
  • 73,366