If you feel like file corruption is one of your major problems, consider moving the entire OS away from the SD-card. On a Raspberry Pi 1 / 2 / Zero (W) you need at least some boot files on the SD-card but you can run the rest from a USB device. With a freshly downloaded image:
- Copy the entire Raspbian image to a USB-device.
- Copy (only!) the
/boot/ partition to an SD-card.
Attention for the next 2 steps / edits: these paths are followed by a number. Don't edit or remove the number! (
sda2, etc. ...).
cmdline.txt in the
/boot/ partition on the SD-card and change
/dev/sda. Consider editing the same file in the
/boot/ partition on the USB device so you have a ready-to-use backup of your
/etc/fstab and change
/dev/sda on the USB device.
Done! You can make the
/boot/ partition your SD-card read-only (but there wouldn't be any writes anyway). Also, if the SD card would ever fail again, you have a backup of the
/boot/ partition on your USB device.
If you have a Raspberry Pi 3 B, perform these extra steps (on top of the previous steps) to not need an SD-card at all.
- Boot Raspbian (with the SD-card)
- Update/upgrade your Raspbian OS
/boot/config.txt on the SD-card, add a new line at the end with:
- Reboot (Raspbian will enable USB boot mode during this boot cycle)
Done! Shut down, remove the SD-card from the Raspberry Pi 3 B and boot again. This will take longer than usual. Mine did a strange sequence on it's own: I put the power in, then it showed a color image, it rebooted on it's own, showed the color image again, rebooted on it's own again, showed the color image again and suddenly booted into Raspbian. The next reboots were much faster.
Make sure to remove the
program_usb_boot_mode=1 line in
/boot/config.txt on the SD-card if you plan on reusing the SD-card in other Raspberry Pi's that don't need USB boot mode enabled.