Raspberry Pi online course

Expand the Raspberry Pi OS Filesystem with raspi-config

Learn how to expand a Raspberry Pi OS root filesystem into unused SD-card capacity with raspi-config, then verify the result safely.

A Raspberry Pi OS installation can show much less storage than the capacity printed on the SD card. This usually happens when an operating-system image was written to a larger card but its original partition layout was not expanded. The raspi-config utility can usually enlarge the root partition and its filesystem so the operating system can use the remaining space.

Why filesystem expansion is needed

An SD card has a physical capacity, such as 32 GB or 64 GB. That capacity is divided into regions called partitions. A partition is a defined area of a storage device that holds a filesystem or other disk data.

The root partition contains the Raspberry Pi OS root filesystem. The root filesystem is the main Linux filesystem mounted at /; it contains the operating system, installed software, and most user data.

An operating-system image may have been created with a relatively small root partition. When that image is written to a larger SD card, the card can contain:

  • A boot partition used by the Raspberry Pi during startup.
  • A root partition containing Raspberry Pi OS.
  • Unallocated space, meaning capacity that is not assigned to any partition.

Unallocated space is not available for ordinary files. The root partition must first be enlarged into that space, and then the root filesystem must be expanded to use the enlarged partition. Filesystem expansion is the second part of this process: it increases the filesystem's usable size after its underlying partition has been enlarged.

When expansion is appropriate

Manual expansion is appropriate when the root filesystem is smaller than the available storage on the SD card. A common example is writing an image designed for a small card to a 32 GB card. The image may initially use only a few gigabytes even though the card has much more capacity.

Do not assume expansion is required. Some modern imaging tools and first-boot setup workflows automatically resize the root partition. Traditional NOOBS installations also commonly expanded the root partition during setup. Check the current root filesystem size before changing the partition layout.

Installation or storage situationIs manual expansion usually needed?What to check
Fresh image written to a larger SD cardOften yesCompare df -h / with the device and partition sizes shown by lsblk.
NOOBS installationUsually noCheck whether the root filesystem already uses the available card capacity.
Modern first-boot automatic resize workflowUsually noRun df -h / after setup has completed.
Custom or multi-partition layoutNot necessarilyInspect the complete layout before resizing; the root partition may not be next to free space.
Booting from USB or external storageDepends on the device and layoutUse findmnt / to identify the actual root device before changing anything.

Safety checks before resizing

  1. Confirm the boot device. Make sure the running system is booted from the SD card you intend to expand. Do not resize a different card or external drive by mistake.
  2. Back up important data. Partition changes are normally straightforward, but a power failure, storage fault, or existing corruption can make a system unbootable. Keep a backup of files you cannot replace.
  3. Use reliable power. Connect a dependable power supply and avoid unplugging the Raspberry Pi while the partition or filesystem is being changed.
  4. Check the current layout and capacity. This establishes whether expansion is needed and identifies the root device.

Use these commands in a terminal:

df -h /

df reports filesystem disk-space usage. The -h option displays sizes in a human-readable format, and / limits the report to the root filesystem.

lsblk

lsblk lists storage devices, partitions, and their sizes. Look for the device that contains the mounted root partition and compare its total size with the partition size.

findmnt /

findmnt / confirms which device and filesystem are mounted as the root filesystem. This is especially important when the Raspberry Pi can boot from USB, an SSD, or more than one storage device.

Expand the filesystem with raspi-config

raspi-config is a menu-driven Raspberry Pi OS configuration utility. It provides system settings, including an action for expanding the root filesystem.

  1. Open a terminal. If you need a refresher, see using the Raspberry Pi terminal.
  2. Start the utility with administrative privileges:
sudo raspi-config
  1. Find the filesystem expansion action. Depending on the Raspberry Pi OS release, it may be labelled Expand Filesystem, Expand Root Filesystem, or similar.
  2. The menu position can vary. Older releases may show the option prominently, while newer releases may place it under an advanced or storage-related menu.
  3. Select the expansion option and accept the prompts displayed by your installed version.
  4. Exit raspi-config when it reports that the action has been requested or completed.

The tool adjusts the root partition into suitable remaining SD-card space and expands the root filesystem to match. It cannot create capacity that the storage device does not physically have.

Reboot and confirm the result

A reboot is required so the new partition layout can take effect and the operating system can recognize the changed size. Restart the Raspberry Pi with:

sudo reboot

After the Raspberry Pi starts again, check the root filesystem:

df -h /

A successful expansion normally shows a substantially larger value in the Size column and more available space in the Avail column. The exact displayed size may be slightly less than the card's advertised capacity because of filesystem overhead, the boot partition, and differences between decimal and binary capacity units.

Use the following commands if you need to verify the partition layout as well:

lsblk
findmnt /
CommandPurposeWhat indicates success
df -h /Displays total, used, and available capacity for the root filesystem.The root filesystem has a size consistent with most of the available card space.
lsblkShows storage devices, partitions, and their sizes.The root partition is larger and there is no expected unallocated area after it.
findmnt /Identifies the device and filesystem mounted at /.The reported root device is the SD-card partition that was expanded.

Automatic expansion and exceptions

Some installation methods perform the resize automatically. NOOBS-based installations traditionally expanded the root partition during setup. Modern imaging and first-boot workflows may also enlarge the root filesystem the first time the system starts.

Run df -h / and lsblk first. If the root filesystem already occupies nearly all usable storage, running another expansion is unnecessary.

Limitations and edge cases

  • Physical capacity is a limit. Expansion cannot exceed the actual capacity of the installed SD card, USB device, or SSD.
  • Free space must be suitable. A straightforward expansion generally requires contiguous unallocated space immediately after the root partition. Free space elsewhere on the device may not be usable by raspi-config.
  • Custom layouts may need another method. Encrypted storage, multi-boot installations, unusual partition arrangements, and custom filesystems may require specialist partition and filesystem tools.
  • External storage changes the procedure. If the root filesystem is on USB storage or an external drive, identify that device with findmnt /. Do not assume the SD card is the root device.
  • Expansion does not remove existing data. If the filesystem is genuinely full because of files, logs, package caches, or projects, identify and clean up those files or use larger storage.
  • Expansion does not repair failing media. A worn, corrupted, counterfeit, or read-only SD card can continue to report errors after a resize attempt.

Troubleshooting

The expansion option is not visible

The menu wording and location vary between Raspberry Pi OS releases. Inspect advanced or storage-related menus in raspi-config, then check the current layout directly:

df -h /
lsblk

The option may also be absent because the root filesystem is already expanded.

The card is large, but df still shows a small root filesystem

First confirm that you inspected the correct filesystem and device:

findmnt /
lsblk

Possible causes include an incomplete resize, a root partition that is not adjacent to unallocated space, or an installation using a different storage device. Do not repeatedly modify the layout until you have confirmed that a backup exists.

raspi-config says the root filesystem is already expanded

Automatic resizing may already have occurred, or the installer may have used all suitable space from the beginning. Verify the usable capacity with:

df -h /

If the available space is still low, investigate large files and package caches instead of attempting another resize. A larger storage device may be the appropriate solution.

The Raspberry Pi will not boot or the storage becomes read-only

A power interruption during storage writes, SD-card wear, corruption, or counterfeit media can cause these symptoms. Power off safely if possible, inspect the card from another computer, and restore from a backup or rewrite the operating-system image if necessary. Use a known-good card and a stable power supply.

The card appears smaller than its advertised capacity

Some difference is normal because manufacturers use decimal units while operating systems often display binary-style units. Compare the device size shown by lsblk with the expected capacity. A much larger discrepancy may indicate defective or counterfeit media.

Practical example: a 32 GB card with a small root filesystem

Suppose a 32 GB SD card contains a Raspberry Pi OS image whose root filesystem is only a few gigabytes. Run df -h / and see a small root size, then use lsblk to confirm that the SD-card device is much larger than its root partition.

  1. Back up important files and confirm the Raspberry Pi is booted from that SD card.
  2. Run sudo raspi-config.
  3. Select the filesystem expansion action, accepting the prompts shown by the installed release.
  4. Reboot with sudo reboot.
  5. Run df -h / again. The root filesystem should now use most of the card's usable capacity.

Distinguish a small filesystem from a full filesystem

A small root filesystem means the partition and filesystem themselves do not yet use available device capacity. Expansion addresses that layout problem. A full filesystem means the existing filesystem has little free space because files already consume it. Expansion will not automatically remove files or solve a failing card.

For more disk-space investigation, see checking disk space and useful terminal commands. For broader configuration guidance, see raspi-config.

Key points

  • The SD card's physical capacity and the root filesystem's usable size are not always the same.
  • Unallocated capacity cannot store normal files until the root partition and filesystem are expanded.
  • Check df -h /, lsblk, and findmnt / before changing storage.
  • Use sudo raspi-config, select the filesystem expansion action, and reboot.
  • Automatic first-boot resizing may mean no manual action is needed.
  • Back up data and avoid power loss during partition or filesystem changes.