I'm not all that keen to buy a USB hard disk, but I'm aware that SD cards aren't suitable for many repetitions of reading and writing.
Are there any steps I can take to extend the life of my SD card while it's being used by my Raspberry Pi?
|
I'm not all that keen to buy a USB hard disk, but I'm aware that SD cards aren't suitable for many repetitions of reading and writing. Are there any steps I can take to extend the life of my SD card while it's being used by my Raspberry Pi? |
|||||
|
|
These methods should increase the lifespan of the SD card by minimising the number of read/writes in various ways: Disable SwapSwapping is the process of using part of the SD card as volatile memory. This will increase the amount of RAM available, but it will result in a high number of read/writes. It is unlikely to increase performance significantly. Disable swap with the
You must also prevent it from coming back after a reboot:
Disabling Journaling on the FilesystemUsing a journaling filesystem such as You can disable journaling on You can disable journaling on
The noatime Mount FlagAssign the noatime mount flag to partitions residing on the SD card by adding it to the options section of the partition in
Directories in RAMHighly used directories such as
This will allow Directories in external Hard DiskYou can also mount some directories on a persistent USB hard disk. More details of this can be found in this question. The Raspberry Pi can also boot it's root partition from an external drive. This could be via USB or Ethernet and means that the SD card will only be used to delegate to different device during boot. This requires a bit of kernel hacking to accomplish, as I don't think the default kernel supports USB storage. You can find more information at this question, or this external blog post. |
|||||||||||||
|
|
One option to extend it's life substantially is to use an SD card which is much bigger than you need. Most decent SD cards use wear levelling algorithms to minimise the number of times each block is written, so if the SD card is bigger than you need the wear can be spread over a much larger area of free space. Part of the reason wear levelling is so important is that some file systems, such as FAT (the default format for many SD cards), hammer the same sectors over and over again. For more information on this, see the answers to the question Is it true that a SD/MMC Card does wear levelling with its own controller? over on Electronics Stack Exchange, especially this answer. One interesting statistic from this answer is that
But the worrying thing is that
This may make your choice of file system important if you need to guarantee reliable storage. One final note: Doubling the size of the SD card could more than double the longevity of it. I.e. if you have a 2 GB SD card with 200 MB free then switching to a 4 GB card will give you 11 times the free space, wear levelling capacity and thus longevity, while switching to a 16 GB card will give you 71 times the free space. |
||||
|
|
|
The only thing I see is to NOT swap on the SD card. Swapping on the Sd card is probably what could kill your SD card. If you need more RAM, you can try to use zram, theres a post on http://raspberry.pi.gw.gd/t50-Using-ZRAM.html giving some details about using ZRAM on the raspberry pi More info for zram on http://en.wikipedia.org/wiki/ZRam Also the most recent SD cards are know to be much more solid than older ones, buying a brand new class 10 SD card is probably a good option is you want to see it last a long time. |
|||
|
|
|
You could try running Puppy Linux which is completely ram-resident. It's very small and blindingly fast since it runs completely in memory by copying the storage image (on SD card in your case) into RAM at boot and then flushing changes periodically back to storage. The frequency of this save is user controlled including manually. Puppy uses the layered aufs or older unionfs filesystem underneath any of the standard Linux filesystems like ext3 or ext4. It can also reside on FAT, or NTFS partitions. There are at least a couple of versions of Puppy specifically designed for the RPi, one of them created by the "Puppy Master", Barry Kauler. For more, go to http://puppylinux.org/wikka/Puppi |
|||
|
|
|
Flash Cell Endurance:
It is purely mathematical on large cards and normal wear. If you were to write to a 8GB MLC type flash card day and night over and over it would take about 30 days to kill it. Episode 99 at Techsnap talks about wearing out SSD's and Allen explains how it is impossible to wear out a SSD in everyday usage and we do not need to worry about disabling swap, crons and all that. It just works now! The smart wear levelling takes care of everything. Normal wear as quoted per Kingston should give you 27 years of life for the life in a professionals digital camera. The price of flash has fallen and the technology is a lot better. Most SD cards will outlive two or three generations of devices and by that time it will be considered to small and too slow to use with a much better and cheaper upgrade available! |
|||||||
|
|
Disable Swapfile:
There is no necessity to uninstall, however if you are not using it, and do want the space, you can safely remove it. Alternate command to remove:
Usage: /sbin/dphys-swapfile {setup|swapon|swapoff|uninstall} |
|||
|
|