Tuesday, February 23, 2016

Resize Linux Partition

I had the case of wanting to resize a linux partition for my Raspberry pi without access to the usual raspi-config tool so had to do it manually.
The raspi-config tool doesn't require a reboot, so there are probably other ways to achieve it as well, but this way works for me.

First I had a full disk. Which you can see by running the df command with -h for human readable output.


I want to expand the space for the / mount point that is at 100%
You can see that there is a partition at /dev/mmcblk0p1 , the p1 refers to partition 1 so that is device /dev/mmcblk0 but what partition is the / mount point?

You can check the partitions on the device with the fdisk -l command which lists them. 

So you can see that we want to expand the partition /dev/mmblk0p2 on device /dev/mmblk0

You also use fdisk on the device to delete and recreate the partition, then write the results back. This is done on partition 2 even though partition 2 is the linux partition on the running system.


It says the partition was altered, but the device is busy. It also says the device is busy for the next commands so the next step was to reboot.

After the reboot, run resize2fs on the partition that changed size.


If it ran successfully, you can df -h again to see the new space that is now available.
  

The space is now available for you to use.





No comments:

Post a Comment