answered
2016-05-08 18:09:58 +0200
Tips to extend life of a SD card:
Hardware
- Prefer cards that feature Static Wear Leveling in addition to your garden variety Dynamic Wear Leveling.
With this the wear leveling will also cycle through the static blocks that don't get written to.
(i.e.: your old files will get periodically refreshed, and the wear-leveling is spread over the whole device and not only over the few blocks that get written and the extra free pool. The later dramatically help flash wear endurance) - Prefer cards that feature ECC (error correction)
- Prefer cards with as many "Allocation Units"/"segments"/"Erase Block groups" kept in RAM cache.
NOTE: few constructors directly advertise this kind of low-level spec. If you can't catch an engineer on the customer service, at least try to get the "Pro" version of product line (usually the one with ECC). Or even the "Industrial" version (designed to be nearly indestructible in very harsh environments and usage patterns) but be prepared to pay a very high price tag.
In my experience Transcend's Ultimate serie is good. It features ECC (even advertised on the website !) and according to the engineers I've spoken to, it also uses static wear-leveling.
Don't bother with "Best microSD card"-style reviews. These review are mostly useless: the only thing they test is out-of-box read/write speed on fresh data (i.e.: they won't even detect things as simple as read speed decay like Samsung 840 EVO with older firmware were plagued). They don't give the slightest useful information about long term reliability.
Software
When formatting your microSD card :
- Try to align it to allocation units of the flash.
- Basically, look at the partition table (
fdisk -l /dev/mmcblk0
). If the originsl partition is aligned to 8MiB, that means you need to also align your newly created partition to 8Mib. - In case of FAT32 / exFAT (ew....) try also aligning the FAT tables so it ends at an allocation unit boundary, and the data clusters begin at the next au. (e.g.: Partition starts at 8MiB, FAT(s) is between 8MiB and 16MiB, content of first file (usually root directory) begins at 16MiB). The link about has the gory details about how to do it.
- FAT32 and exFAT (ew....) aren't very good for flash as they constantly write at the same place (on the FAT table. Hence the advantage of keeping it packed inside 1 au which can be kept by the card within one of its RAM cache)
- Prefer file systems that are either copy-on-write or log-structured, they are much gentler on flash
- BTRFS is CoW
- it means it never overwrites anything, but writes a new copy, and eventually garbage collects the old copy (unless that copy is kept as part of a snapshot subvolume)
- it's also checksumed, so it's trivial to check data integrity by using
btrfs scrub start
. - snapshot subvolume are a very handy tool to keep some simple sort of backups (it won't save you in case of lost/burnt SD card, but you can revert to an earlier version, in case of data corruption / hardware starting to fail and refusing further writes)
- it is also Sailfish OS default native format, meaning it is supported. See this answer or that answer about how to do it in a compatible manner.
- F2FS is log-structured file system
- it means that the whole system is a kind of journal. Each write is a new journal entry. (and the oldest entries will get garbage collected when free space needs to be claimed - as long as data of those entry has been deleted)
- DO BACKUPS !!! And to insist again: DO BACKUPS !!!
- It's a phone. Even if you use the best microSD card and the stablest filesystem ever, your phone can still get lost, stolen or heavily damaged.
- Have a look at BTRFS's snapshots, it comes handy to help organise you backups (though currently BTRFS's send / receive seem not to be working, so you'll have to resort to
rsync
in the meantime for uploading part) - Again, DO BACKUPS !!!
- Avoid putting swap on flash media, unless you know exactly what you're doing. It puts a lot of stress on the flash media, so use media able to sustain it.
In my personnal experience:
- I've killed a Lexar 633x in a couple of days. (Luckily it was under Warranty).
- I've killed a Samsung EVO in a couple of months. (Luckily, warranty again).
- My current Transcend Ultimate (ECC + Static wear levelling) is still happily chugging along after nearly one year, with no sign ever of wear or physical corruption.
NOTE: the draw back of switching your partition to BTRFS is that it's not widely supported outside Linux (though the situation is starting to change ).
I should definitely hurry up getting UDF working on Sailfish OS. It's log-structured, but it's supported on Windows / Mac OS X too.
Nice, thnx. I experienced something like this myself. It looks like the sd-card was a bad one, because I used it for less than a year. Or could it be that Sailfish writes a lot more caching to the sd?
Xmasjos ( 2016-05-08 01:45:36 +0200 )edithi @Xmasjos ,well i used this sd-card for over 3 years and i used it quite heavily. 10gb permantly used and on the 20gb rest i wrote in these 3 years ~300gb. this should not be enough to wear out the flash but its more than most people write to it i guess. it was in my jolla for the last 1.5 years. i have seen the tracker create some files on the card, but im not aware of many write accesses... (im not somebody who would know anyway)
misc11 ( 2016-05-08 09:37:40 +0200 )edit