Raspberry Pi SD Card Safety for Home Assistant in 2025
In this article
Yes, running Home Assistant from a Raspberry Pi SD card is now significantly safer than it used to be, but it still carries a higher risk of corruption compared to an SSD or eMMC. The two biggest threats—excessive write cycles and power loss—have been largely mitigated by Home Assistant's move to a read-only root filesystem and the recent addition of the zram swap feature, but you should still take precautions.
Why SD Cards Were Historically a Problem
For years, the default advice in the Home Assistant community was to avoid SD cards entirely. The reason is that SD cards have a limited number of write/erase cycles, and early Home Assistant installations wrote logs, telemetry, and database data constantly to the card. The built-in SQLite database (used for the history and logbook) was particularly write-heavy. Combined with the fact that a sudden power cut can corrupt the filesystem, many users experienced the dreaded “read-only file system” error or a card that simply died after a few months.
What Changed: Read-Only Root and zram
Home Assistant OS (the recommended installation method) now runs the root filesystem in read-only mode. This means the operating system files are mounted as immutable, so they cannot be accidentally modified or corrupted by a bad write. Logs and temporary files are stored in a RAM-backed filesystem (tmpfs), which disappears on reboot. The most significant change is the introduction of zram as the default swap mechanism. Instead of writing swap data to the SD card, zram compresses memory in RAM, dramatically reducing the number of writes to the card. The Home Assistant database is still stored on the SD card, but the write pattern is much less aggressive than before.
How to Check Your Current Setup
If you are already running Home Assistant OS on a Raspberry Pi, you can verify these protections are active:
- Open the Settings → System → Storage page in the UI. You should see a “zram” entry listed as a storage location.
- In the terminal (via SSH or the “Terminal” add-on), run
mountand look for the root filesystem mounted asro(read-only).
These two indicators confirm that your system is using the safer architecture.
What Still Poses a Risk
Despite the improvements, the SD card is still the most fragile component in a Raspberry Pi setup. The following factors can still cause failure:
- Power outages: A sudden loss of power while the card is being written can corrupt the filesystem, even with a read-only root. The data partition (where your configuration and databases live) is still read-write.
- Heat: Raspberry Pi 4 and 5 models run hot, and prolonged high temperatures can degrade the card’s NAND flash.
- Cheap or counterfeit cards: Many “high capacity” cards sold at low prices are fake and fail quickly. Always buy from reputable brands and authorized resellers.
- High write loads: If you run write-heavy add-ons (like certain databases, or the
recorderwith a long history), you are still writing to the card.
How to Choose an SD Card (and When to Skip It)
If you decide to stick with an SD card, choose one designed for endurance. Look for cards with an A2 rating (for random read/write performance) and a high endurance rating. For example, the “High Endurance” or “Max Endurance” lines from major manufacturers are designed for dashcams and surveillance systems, which have similar write patterns to a Home Assistant setup. Avoid standard “Class 10” cards that are not rated for continuous writes.
However, if you are setting up a new system, consider these alternatives:
- SSD via USB: The most popular upgrade. It is faster, more reliable, and not much more expensive than a good SD card. You can boot directly from an SSD on Raspberry Pi 4 and 5.
- eMMC module: Available on the Raspberry Pi Compute Module 4 and 5. It is essentially a built-in SSD and is the most reliable option, but it requires a carrier board.
- Network boot: Booting from a network drive is possible but complex and not recommended for beginners.
Best Practices for SD Card Longevity
Even with the safer architecture, you can extend the life of your SD card with these habits:
- Always shut down properly: Use the “Power Off” button in the UI before unplugging the Pi. This flushes pending writes.
- Use a UPS or a good power supply: A small uninterruptible power supply (like a battery hat) can prevent corruption from power loss. At minimum, use the official Raspberry Pi power supply.
- Keep the Pi cool: Use a heatsink and fan. The official case with a fan is a good choice.
- Back up regularly: Use the built-in backup feature (Settings → System → Backups) and store backups on a separate device, like a NAS or a USB drive.
- Monitor your card health: The
smartctlcommand is not available for SD cards, but you can check for errors in the system log. If you see I/O errors, replace the card immediately.
Frequently Asked Questions
Is a Raspberry Pi 5 with an SD card better than a Pi 4 with an SSD?
No. The SSD will always outperform an SD card in terms of reliability and speed, regardless of the Pi model. The Pi 5 is faster, but the SD card remains the bottleneck. If you have the budget, an SSD is the better investment.
How often should I replace my SD card?
There is no set timeframe. It depends on the quality of the card, the write load, and the environment. A good high-endurance card can last several years, while a cheap card might fail in months. Monitor for signs of failure (slow UI, frequent errors) and back up regularly.
Can I run Home Assistant from a USB flash drive instead of an SD card?
Technically yes, but it is not recommended. USB flash drives have the same write endurance issues as SD cards, and they are often slower. An external SSD is a much better choice.
Does using the “SSD” mode on a Raspberry Pi 4 make a difference?
Yes. The Raspberry Pi 4 supports USB boot, which allows you to boot from an SSD. This is the most reliable method and is officially supported. The Pi 5 also supports USB boot, but it requires a USB 3.0 cable and a compatible enclosure.
What is the best way to migrate from an SD card to an SSD?
The easiest method is to use the Home Assistant “Backup” feature. Create a full backup, then flash Home Assistant OS to the SSD using the Raspberry Pi Imager. Boot from the SSD and restore the backup. Alternatively, you can clone the SD card using a tool like dd or Balena Etcher, but this can be error-prone.
Is it safe to turn off the Pi by just unplugging it?
No. Even with the read-only root, unplugging the Pi can corrupt the data partition. Always use the “Power Off” option in the UI, and wait for the green LED to blink or turn off before unplugging.