VMware ESXi and vSphere Cluster Management
Expand the Raspbian Root Filesystem on a Raspberry Pi
Learn how to expand a Raspbian root filesystem with raspi-config so a Raspberry Pi can use the remaining capacity of its SD card.
A Raspberry Pi installation can report much less usable storage than the physical capacity printed on the SD card. This commonly happens when an operating-system image creates a root partition that is smaller than the card. The remaining space exists on the card, but it is not available for ordinary files until the partition and its filesystem are expanded.
Why filesystem expansion is needed
Raspbian is the older name for the Raspberry Pi operating system now commonly called Raspberry Pi OS. Its main Linux storage area is the root filesystem, mounted at /. It contains the operating system, installed applications, configuration files, and most user data.
A partition is a defined section of a storage device. The root partition is the partition that contains the root filesystem. An operating-system image may initially create a root partition sized for the image rather than for the entire SD card.
For example, a system image with a root partition of only a few gigabytes can be written to a 32 GB SD card. The SD card has more physical capacity, but the root filesystem cannot use that capacity until the root partition grows into adjacent unallocated space. The filesystem must then be expanded to fill the larger partition.
Typical symptoms of a small root filesystem include:
- Package installation fails because there is not enough space.
- System updates cannot download or unpack files.
- Copying documents, photographs, or project files reports a disk-space error.
- Logs and temporary files consume the remaining free space.
When expansion is appropriate
Filesystem expansion is useful after writing an image to an SD card larger than the image's initial root partition. The standard raspi-config method is intended for a typical Raspberry Pi installation using the usual boot partition and root partition layout.
Some installations already expand automatically and therefore do not need this step. In particular, systems installed through the historical NOOBS installer generally expanded the root partition during installation. If the root filesystem already occupies almost all available card space, running the expansion procedure will not provide a meaningful increase.
Custom partition layouts, encrypted installations, USB boot devices, and other nonstandard storage arrangements may require different tools or procedures. The instructions below should not be treated as a universal method for every storage layout.
Before making partition changes
Partition and filesystem changes are normally safe when the storage layout is supported, but an interruption or storage failure can make the system unavailable. Back up important files first. For a stronger recovery option, create an image of the SD card before resizing it.
| Check | Why it matters | How to verify |
|---|---|---|
| Important data is backed up | A failed resize or damaged card can cause data loss. | Copy important files elsewhere or create a full SD-card image. |
| The device is running from the intended SD card | You must resize the storage containing the active installation. | Use lsblk and identify the device containing the / mount point. |
| Unused capacity exists on the card | Expansion can use only capacity that is not already assigned to another partition. | Compare the whole device size and partition sizes with lsblk. |
| The root partition is eligible to grow | The usual automatic method expects suitable unallocated space after the root partition. | Inspect the partition order and mount points with lsblk. |
| Reliable power is available | Power loss during resizing can damage partition or filesystem metadata. | Use a stable power supply and avoid working during power interruptions. |
| The installation was not already expanded automatically | An already full-size root partition has no useful expansion left to perform. | Run df -h / and compare the result with the card's expected capacity. |
Expansion cannot exceed the actual capacity of the card. Also remember that the capacity printed by manufacturers uses decimal units, while many Linux tools display binary units. A card labeled 32 GB will therefore appear smaller in some command output. Boot, system, formatting, and filesystem overhead also reduce the space available to files.
Do not interrupt power, shut down forcefully, or remove the SD card while partition or filesystem resizing is in progress.
Check the current storage layout
Before changing anything, check how much space is available on the mounted root filesystem:
df -h /
The output includes a line whose mount point is /. The important columns are usually Size, Used, Avail, and Use%. This line describes the filesystem currently used as the Raspberry Pi's root filesystem.
To inspect the physical device, partitions, sizes, and mount points, run:
lsblk
Look for the device containing the partition mounted at /. Check whether the card's total size is larger than the root partition and whether another partition occupies the space after it. The standard expansion method normally needs suitable unallocated space immediately following the root partition.
Expand the filesystem with raspi-config
raspi-config is a terminal-based Raspberry Pi configuration utility. Open it with administrative privileges:
sudo raspi-config
- Use the arrow keys to move through the text-based menu.
- Use Enter to open the highlighted category or select an item.
- Use Tab to move between menu controls such as OK and Cancel.
- Select the item named Expand Filesystem, Expand Filesystem under advanced options, or equivalent wording.
The exact menu placement and wording can vary between Raspbian releases. If the item is not on the first screen, check advanced or storage-related categories. Some versions may proceed without showing another confirmation prompt.
When selected, the utility schedules or performs the operations needed to enlarge the root partition and then expand the root filesystem into that partition. If the utility asks you to exit, choose the appropriate exit option. If it requests a reboot, accept it or restart manually:
sudo reboot
Reboot and completion behavior
Resizing may be finalized during reboot rather than entirely while raspi-config is open. The first reboot can take longer than usual, especially with a large card or slower Raspberry Pi hardware.
Allow the Raspberry Pi to finish booting. Do not remove the SD card or disconnect power while the operation is being finalized. A longer first boot is not automatically a sign of failure.
Verify the result
After the Raspberry Pi has booted, check the root filesystem again:
df -h /
Inspect the row whose mount point is /. Its Size and Avail values should be substantially larger if the expansion succeeded. The reported root filesystem size should be close to the usable capacity of the SD card, allowing for the boot partition, other system partitions, formatting differences, and binary-versus-decimal units.
For additional diagnosis, compare mounted filesystems with the device and partition layout:
lsblk
df reports mounted filesystem capacity, while lsblk reports block devices and partitions. Using both commands helps distinguish a small filesystem from a partition-layout problem.
Common expansion outcomes
| Outcome | Likely explanation | Recommended next step |
|---|---|---|
| Root filesystem becomes larger after reboot | The root partition and filesystem expanded successfully. | Keep sufficient free space for updates and normal operation. |
| No size change after running the option | The action may not have been selected, a reboot may still be required, or the layout may not be supported. | Run df -h /, reboot if needed, and inspect the layout with lsblk. |
| Filesystem was already using most of the card | The installation was already expanded, possibly automatically. | No further expansion is normally necessary; investigate other causes of low free space. |
| No unallocated space follows the root partition | Another partition occupies the remaining capacity, so the root partition cannot grow into it automatically. | Use a partitioning procedure appropriate to the actual layout, after making a backup. |
| System fails to boot after an interrupted resize | Power loss or card removal may have damaged partition or filesystem metadata. | Protect recoverable data, restore a backup or known-good image, and replace unreliable storage if necessary. |
Troubleshooting
The root filesystem is still small after reboot
- Run
df -h /and confirm which filesystem is mounted at/. - Run
lsblkto compare the SD card's total size with its partitions. - Reopen
sudo raspi-configand verify that the correct filesystem expansion option was selected. - Check whether another partition is directly after the root partition.
- Consider whether the system is using USB storage, encryption, or another nonstandard layout.
The expansion option is absent or worded differently
Menu organization differs between releases. Check advanced or storage-related categories, and verify the current root filesystem size before making changes. If the system uses a newer configuration interface or a custom layout, use tools appropriate to that installed operating system rather than forcing the standard procedure.
The option completes but no extra space is available
The card may already be fully allocated, the root partition may not be followed by free space, or the physical card may report an unexpected capacity. Compare the device and partition sizes with lsblk. If the reported capacity is inconsistent, test the card or replace it with reliable storage.
The first boot takes a long time
Partition or filesystem resizing may still be finishing. Slow SD cards and larger capacities can increase the time required. Wait and avoid removing power. Investigate only if the system remains unresponsive well beyond its normal boot behavior.
The system was interrupted during resizing
Do not continue making unnecessary writes to the affected card. Recover important data from a backup or restore a known-good operating-system image if necessary. Storage errors can cause repeated failures, so replace an unreliable SD card before trying again.
Limits and safety considerations
- Expansion increases available storage; it does not increase RAM, processor performance, or SD-card reliability.
- The root partition normally grows into adjacent unallocated space. It cannot safely consume space already occupied by another partition without redesigning the layout.
- The usable capacity is lower than the card's label because of decimal manufacturer units, binary operating-system units, boot partitions, formatting, and system overhead.
- Keep free disk space after expansion. Updates, logs, temporary files, and package operations need working room.
Quick reference
| Command | Purpose | What to look for |
|---|---|---|
sudo raspi-config | Open the Raspberry Pi configuration utility. | Select the release-appropriate filesystem expansion item. |
df -h / | Check root filesystem capacity and free space. | Inspect the row with the / mount point before and after reboot. |
lsblk | Inspect disks, partitions, sizes, and mount points. | Identify the active root partition and whether suitable unused capacity follows it. |
sudo reboot | Restart so pending resize work can complete. | Allow the first boot to finish without interruption. |
Once verification shows that the root filesystem has grown, the remaining SD-card capacity can be used for applications, updates, files, and projects. If the root filesystem was already full-size or no suitable unallocated space exists, the standard raspi-config operation is not the correct next step.