resizing the raspi flash card

Before running fdisk I brought the system down to single user and remounted the root partition read-only. In the following the # is root’s prompt.

# systemctl rescue
# mount -o ro,remount /
# fdisk /dev/mmcblk0

Delete the second partition /dev/mmcblk0p2.

d
2

Create a new primary partition and use default sizes prompted. This will then create a partiton that fills the disk.

n
p
2
enter
enter

Save and exit fdisk:

w

Reboot, go single user, and run resize2fs:

# shutdown -r now
# systemctl rescue
# resize2fs /dev/mmcblk0p2

Your main / partition should be the full size of the disk now. Don’t remount the root partition read-only before you run resize2fs; resize2fs fails if it’s mounted read-only.

After running resize2fs reboot, go to single user, remount root read-only, run e2fsck, then reboot to bring the system back up multi-user:

# shutdown -r now
# systemctl rescue
# mount -o ro,remount /
# e2fsck /dev/mmcblk0p2
# shutdown -r now

Advertisements


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s