Tag Archives: Limit SD Card writes on Raspberry Pi using Ramlog

The Raspberry Pi SD Wear Issue

Raspberry PiReading around the web it is easy to see that SD memory and lifespan are very poorly understood. There are conflicting explanations of lifespan, there are solutions which don’t work because someone didn’t actually test them before writing up … what a mess.

So here’s the deal. SD memory (the type you put in the PI to boot up) has limited write time – SO DOES USB MEMORY.

How long the microSD in your new Raspberry Pi2 will last is anyone’s guess and depends on “disk” activity, i.e. the number of WRITES (the number of READS is irrelevant).

So how to maximise this. It would seem that you CANNOT offload the whole thing to a hard drive.. but you can have the Pi boot up from the microSD – and then do everything ELSE on the hard drive. You cannot power the hard drive off the USB on the Pi as it does not provide enough juice – so you’d need a powered USB hub. This article looks good – I only got as far as transferring files externally so don’t ask me questions on it – but this seems to be one of the better explanations for using an external file storage. https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=44177

Another way to improve the life of the SD and one that makes sense to me is a RAMDRIVE. That is instead of allowing the Pi to write constantly to log files on your Pi, have it read all log files into RAM at power up – write to the RAM and then on (intentional) power down, write back to the SD. RAM of course, you can write to forever without issue.

This kind of implies reliable power and I suggest you hunt out an uninterruptable supply – you can sometimes use those little phone charger supplies but I have found that some work, some don’t. The easy way, after backing up your Pi, is to try any one you have lying around. Plug power into the supply, plug the supply into the Pi. Watch the Pi on screen and test the keyboard or mouse. Repeatedly remove and reconnect the power to the supply – if the Pi works without any issue throughout this - then you’re probably onto a winner. I have 2 of them that work, 2 of them that don’t.

Ok, so there is a package called Ramlog which does the job of ensuring the logs are only written at power down. I followed two sets of instructions both of which failed part way through because the writer hadn’t actually tested what he was writing down, missing off a SUDO (super-user-do) command or similar. This explanation http://www.vdsar.net/limit-sd-card-writes-rasberry-pi-using-ramlog/ worked for me.

It would seem that SOME SD memory has something called “wear-levelling” in which the write use of blocks of memory in the chip are evened out so that continuously writing to one block ACTUALLY doesn’t happen as the wear is “spread” – sadly trying to find out how well this works and with which manufacturer’s chips it works – is something akin to dabbling in witchcraft. There is just so much rot out there so personally I’m not counting on it.

Oh and how do you tell if you’re reducing the number of writes – less or no flashing lights on your Pi.

I hope that helps. I’m coming to the conclusion that for long term use an external drive might be a good idea but I think I’ll wait a while until someone comes up with a package or batch file to make this nice and easy – meanwhile Ramlog seems like a good compromise.

About the only thing I did notice is that my SD usage according to WEBMIN before I installed Ramdisk was 3.5GB and after it was 7.10GFB but that’s clearly rubbish – it would be interesting to see it anyone else gets any “special effects”.

Facebooktwittergoogle_pluspinterestlinkedin