Skip Navigation

Best way to keep a hot spare SD card for a raspberry pi?

I have a load-bearing raspberry pi on my network - it runs a DNS server, zigbee2mqtt, unifi controller, and a restic rest server. This raspberry pi, as is tradition, boots from a microSD card. As we all know, microSD cards suck a little bit and die pretty often; I've personally had this happen not all that long ago.

I'd like to keep a reasonably up-to-date hot spare ready, so when it does give up the ghost I can just swap them out and move on with my life. I can think of a few ways to accomplish this, but I'm not really sure what's the best:

  • The simplest is probably cron + dd, but I'm worried about filesystem corruption from imaging a running system and could this also wear out the spare card?
  • recreate partition structure, create an fstab with new UUIDs, rsync everything else. Backups are incremental and we won't get filesystem corruption, but we still aren't taking a point-in-time backup which means data files could be inconsistent with each other. (honestly unlikely with the services I'm running.)
  • Migrate to BTRFS or ZFS, send/receive snapshots. This would be annoying to set up because I'd need to switch the rpi's filesystem, but once done I think this might be the best option? We get incremental updates, point-in-time backups, and even rollback on the original card if I want it.

I'm thinking out loud a little bit here, but do y'all have any thoughts? I think I'm leaning towards ZFS or BTRFS.

54 comments
  • Why not just connect an ssd via USB and save yourself the hassle and torment?

    • That wouldn't solve the problem though would it? It might make it less likely to fail but there's still significant downtime if there's no hot spare for this USB drive.

      • I couldn't count the number of failed sd cards I've seen across all my fingers and toes.

        I've seen like 4 ssds in my entire life fail. Plus you could just do mdraid 1 / btrfs across 2 of them if you want

  • Get a USB to SATA cable. This one works great with the Pi: https://a.co/d/8Jv2Erj

    Instead of having a warm spare, a better solution is to attach two drives and use them in a RAID1 config. Unfortunately, I don't think the Pi supports RAID1.

    • Unfortunately, I don’t think the Pi supports RAID1.

      I haven't ran any Pi with hard drives, but I don't see any reason why it wouldn't work with software raid on linux.

      • The issue is that I don't think its standard bootloader supports booting from RAID. I guess you could use a MicroSD for booting then have everything else on the RAID1. There's unofficial ways to boot using GRUB, which should work with RAID1 too.

54 comments