Recently I’ve had two SD Cards failing on me in a very short period. One of them was acceptable, as it ran 24/7 for almost 4 years, but the other one only worked for one week.
Both failed so bad that no data at all is recoverable.
At this point I’m wondering whether it’s better to just use a USB stick instead. Would that be more reliable?
Sometimes there are power shortages and the Pi looses power. I can’t do anything about it, and a battery backup is not an option in my case.
As a power supply I use a modular PC ATX (Corsair RM750x). The PSU cable that powers the Pi is one with 3 Molex connectors, but i only use one of them with a Molex to Micro-USB adapter and the other ones are left unused (to avoid voltage issues).
I doubt a USB stick would be any more reliable than a SD card because both store the data using flash.
Good article here explaining how to make the SD card last.
- Choose a good quality SD card. I prefer SanDisk. Make sure it’s authentic!!
- Choose a large SD card. The article says:
Although it is not included in the SD specification, a good quality SD Card will use wear levelling algorithms. These algorithms will minimize the number of times each block is written, by arranging data so that erasures and re-writes are distributed evenly across the card. By this way, if the SD card is larger than the space needed, the wear can be spread over a much larger area of free space.
- Reduce read/write cycles. This can be done by logging to RAM. You can also make the SD card read-only.
- Use a more durable storage method Such as a hard drive or solid state drive.
Both SD cards and USB stick will fail in long run as they both have the same flash core. Flash cells have certain write endurance and after number of write cycles, the cells begin to fail.
In a Raspberry pi you can reduce the wear by disabling swap. This is how I disable swap on a newly installed Raspbian OS.
sudo dphys-swapfile swapoff sudo dphys-swapfile uninstall sudo update-rc.d dphys-swapfile remove sudo apt purge dphys-swapfile sudo reboot
Time to time perform a filesystem check (fsck) on your file-system. I do this on Raspbian by:
sudo touch /forcefsck sudo reboot
As mentioned by Botspot, the article gives a good detail on reducing wear on the SD card or other OS media for Raspberry Pi.