{"id":908,"date":"2017-08-07T18:52:18","date_gmt":"2017-08-07T22:52:18","guid":{"rendered":"https:\/\/www.devolve.net\/blog\/?p=908"},"modified":"2017-08-07T14:28:46","modified_gmt":"2017-08-07T18:28:46","slug":"prolong-the-life-of-the-sd-card-in-your-raspberry-pi","status":"publish","type":"post","link":"https:\/\/www.devolve.local\/prolong-the-life-of-the-sd-card-in-your-raspberry-pi\/","title":{"rendered":"Prolong the life of the SD card in your Raspberry Pi"},"content":{"rendered":"

The web is littered with stories of people who love their Raspberry Pis but are disappointed to learn that the Pi often eats the SD card. I’ve recovered a card once, but otherwise had a few that have been destroyed and were not recoverable. I’ll lay out how I use This One Weird Trick(tm), ahem, to try and prolong the life of the SD card.<\/p>\n

First I should point out that my Pi storage layout is not typical. I basically followed this guide<\/a> to boot from SD card, but run the root filesystem on a flash drive. While the stated purpose of the guide is to help reduce activity on the SD card (and improve storage performance somewhat), I come at the SD card corruption issue from a different perspective.<\/p>\n

In my view, the corruption is most likely caused by a timing bug which could be rather low-level in the design or implementation of the hardware itself. Writing to the card less often probably reduces the chances of corruption, but my personal feeling is that after a Pi has been powered on for a certain amount of time, you can’t really predict if the bug is going to manifest. I don’t believe that most instances of SD card corruption happen in the first hours or days of a Pi booting up, so my goal was to only write to it within that initial period of time, if possible.<\/p>\n

After following the guide linked above, the SD card is now only hosting the \/boot partition. After init<\/code> has started on \/ (the external storage), we really don’t need \/boot any longer. In the middle of my \/etc\/rc.local file, I’ve added
\nmount -o ro,remount \/boot<\/code><\/p>\n

In the typical usage of a running system, \/boot doesn’t really need to be mounted read-write. Of course, if you forget it’s mounted read-only, then things like apt-get upgrade<\/code> or rpi-update<\/code> may certainly fail. Now when I want to run those commands I first reboot the Pi, and remount the \/boot partition with
\nsudo mount -o remount,rw \/boot<\/code><\/p>\n

Once the updating is done, I reboot again and leave \/boot read-only.<\/p>\n","protected":false},"excerpt":{"rendered":"

The web is littered with stories of people who love their Raspberry Pis but are disappointed to learn that the Pi often eats the SD card. I’ve recovered a card once, but otherwise had a few that have been destroyed and were not recoverable. I’ll lay out how I use This One Weird Trick(tm), ahem, […]<\/p>\n","protected":false},"author":3,"featured_media":914,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[6],"tags":[34,25,22],"_links":{"self":[{"href":"https:\/\/www.devolve.local\/wp-json\/wp\/v2\/posts\/908"}],"collection":[{"href":"https:\/\/www.devolve.local\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devolve.local\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devolve.local\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devolve.local\/wp-json\/wp\/v2\/comments?post=908"}],"version-history":[{"count":2,"href":"https:\/\/www.devolve.local\/wp-json\/wp\/v2\/posts\/908\/revisions"}],"predecessor-version":[{"id":913,"href":"https:\/\/www.devolve.local\/wp-json\/wp\/v2\/posts\/908\/revisions\/913"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.devolve.local\/wp-json\/wp\/v2\/media\/914"}],"wp:attachment":[{"href":"https:\/\/www.devolve.local\/wp-json\/wp\/v2\/media?parent=908"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devolve.local\/wp-json\/wp\/v2\/categories?post=908"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devolve.local\/wp-json\/wp\/v2\/tags?post=908"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}