Increasing the size of the root filesystem (rootfs) on a Raspberry Pi may be necessary if you need more space for applications, files, or if you are using an SD card or an external hard drive with a larger capacity than the current root partition.
In this tutorial, we will look at a method to extend this partition to take full advantage of your storage capacity.
Type the following command to list the partitions on your hard drive, especially the root one:
df -h
We will now use the Raspberry Pi configuration menu, called Raspi-config, to extend our partition. To do this, you need to type the following command:
sudo raspi-config
Here is the raspi-config menu. Click on 6. Advanced Options:
Once in Advanced Options, click on 1. Expand Filesystem:
You will then see a success message indicating that the root partition has been expanded:
When exiting raspi-config, you will be prompted to restart your Raspberry Pi so that the new configuration can take effect:
After restarting our Raspberry Pi, by retyping the command df -h, we can see our partition has been expanded: