Skip to content
Tutorials Center
My learning

Topics

Lesson 8 of 37 ยท Setup and OS

Storage: SD Cards, SSDs and Booting

Understand Raspberry Pi storage: microSD wear, USB SSD and NVMe boot, partitions, backups with image copies, and how to check disk space and health.

Everything on a Pi lives on its storage: the operating system, your code, your data and your log files. Most beginners use a microSD card, because that is what the board was designed around. It is convenient and cheap but also the weakest part of the system. Understanding how storage works, how it wears out and how to back it up will save you from the heartbreak of a dead card and a lost project.

microSD cards

A microSD card uses flash memory. Every cell can be rewritten only a limited number of times, and cheap cards have simple wear-leveling and slow random writes. A Pi that writes logs constantly, runs a database or swaps memory to disk will wear a card out much faster than one that mostly reads.

Tips for a long card life:

  • Buy a brand-name card with at least 32 GB; extra free space gives the card more room to spread writes.
  • Look for the A1 or A2 rating, which guarantees decent random-access speed.
  • Shut the Pi down properly instead of pulling the plug. See Power, Cooling and Safe Shutdown.
  • Reduce writes: send logs to memory, avoid swap, and keep databases off the card in write-heavy projects.

USB SSD and NVMe

For servers and heavier projects, boot from a solid-state drive instead. A USB 3 SSD on the Pi 4 or Pi 5 is much faster and tougher than a card. The Pi 5 also has a PCIe connector; with an adapter board you can attach an NVMe drive, the fastest option, and boot straight from it.

To switch, you use Raspberry Pi Imager to write the OS to the SSD, or copy a working card to the drive with the SD Card Copier on the desktop. Then set the boot order in raspi-config (Advanced Options, Boot Order) so that USB or NVMe comes first. Current boards ship with firmware that can boot from USB out of the box; very old units may need a firmware update first.

Storage choices

microSD Cheap, slowest, wears out
USB SSD Fast and durable
1 / 2

Partitions and file systems

A storage device is divided into partitions. The standard Pi layout has two:

Partition File system Mounted at Purpose
boot FAT32 /boot/firmware Firmware, kernel, config.txt
root ext4 / The whole operating system and your home folder

Commands to look at them (read-only examples):

Terminal
lsblk                  # tree of block devices and partitions
df -h                  # used and free space per mounted file system
du -sh ~/*             # size of things in your home directory
findmnt /              # where root is mounted

On first boot the root partition is expanded to fill the card, so a 32 GB card gives you nearly 32 GB of usable space (a little less, as card capacity is counted in decimal gigabytes).

Backups

A card can fail without warning, so make a copy of your working system. The simplest full backup is a disk image: a bit-for-bit copy of the whole card into one file. Run it from another computer with the card inserted, never from the running Pi when writing back to the same card.

Terminal
# read-only, on another Linux machine; /dev/sdX is your card
sudo dd if=/dev/sdX of=pi-backup.img bs=4M status=progress
gzip pi-backup.img

Image copies are big because they include empty space. For daily file backups use rsync to copy only your project folders to a network drive or another machine.

Try it: card capacity planner

How much of the card is really usable? The stand-in converts advertised gigabytes to what a computer shows and checks that a plan fits.

Python Stand-in: card capacity planner

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Try it: simulate flash wear

Flash cells survive a limited number of writes. This stand-in is a toy model that shows why writing a small log file every second adds up and why moving writes to memory helps.

Python Stand-in: write-wear estimate

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The numbers are not exact, but the lesson is real: light workloads last for years and write-heavy ones do not.

Reading file system health

If a card begins to misbehave you may see "read-only file system" errors or random freezes. The kernel switches a file system to read-only when it detects errors, to protect your data. Check the log and plan a replacement:

Terminal
dmesg | grep -i -E "mmc|ext4|error"
sudo fsck -n /dev/mmcblk0p2    # read-only check, run only on an unmounted partition

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Why does a microSD card wear out?

    Flash memory cells degrade after many writes, so write-heavy workloads shorten a card's life.
  2. 2. Which storage is the best for a busy home server on a Pi 5?

    SSDs are faster and far more durable than microSD cards.
  3. 3. Which two partitions does the standard Pi image contain?

    The small FAT32 boot partition holds firmware and config; the ext4 root holds the system.
  4. 4. Which command shows free space on each mounted file system?

    df reports used and free space; -h makes the sizes human-readable.

Summary

  • microSD cards are convenient but wear out; buy good ones and reduce writes.
  • SSDs on USB or NVMe are faster and more durable and are best for servers.
  • The standard layout is a FAT32 boot partition and an ext4 root partition.
  • Back up with image copies and rsync, and watch for read-only file system errors.

Next: Power, Cooling and Safe Shutdown