If SD card is defect......what to do?

  • Hello,


    what is the best solution if Micro d (on i.e. Odroid) is defect? I'm asking because want to have a solution before shit happens... :D


    Some wrote to have always some clones in backup. But what does it mean if the System did grow after making the clone? Should I always make a Clon as soon as I put data on the HDD?


    Or should I install an new OMV on a new Micro SD Card. But I'm not sure if and how the HDD with all These data can be used without formatting...


    Any idea/hint?


    thx


    Rudi

  • pre-formatting the card is not required

    While this is true today I would always recommend to do a 'Quick Format' with SD Association's 'SD Formatter' (available only for Windows and macOS unfortunately).


    This tool does the following:

    • Full TRIM over the entire SD card capacity
    • Applying a partition table and a filesystem so the card is afterwards either formatted as FAT or exFAT (depending on size/standard -- all cards larger than and including 32GB are AFAIK ExFAT)

    As @flmaxey said pre-formatting is useless so 2) is of no use here. But we really want 1) for three reasons:

    • A full TRIM on mediocre or crappy SD cards restores performance back to 'factory settings'. Those cards once there has been written more data to than their native capacity get slower. A full TRIM will fix this.
    • The card now operates more efficiently and wears out later since the card controller knows now which pages of the flash media are empty and can exclude them from wear leveling and garbage collection. Doing such a full TRIM from time to time is always a great idea.
    • Since the TRIM marks all pages on the SD card as empty when reading now from the card at the block device layer everything will be returned as zeroes. This is a huge advantage if you do not clone your cards afterwards but create compressed device images with whatever tool.

    To elaborate on the last part: if you reflash an image to SD card without a TRIM in between all already used pages will NOT be overwritten. Say you have a 16 GB SD card and 4 GB on this card had been written to. If you now burn a new image on this card that is 1 GB in size then the following happens:


    If you look at the card at the filesystem layer 1 GB is used only (less used). If you sync the card's contents now with eg. rsync only 1 GB will be copied. When you do a clone of the card at the block device layer the whole 16 GB will be copied and 5 GB (4 + 1) contain data. Such data does not compress that great compared to only zeroes. So with a clone of such a 16GB card with applied compression and a notional 1:2 compression ratio for the 'used data' we end up both times with an image of 16 GB size uncompressed. But the compressed size of the non-trimmed image will be 2.5 GB (5 GB / 2) vs. 500 MB (1 GB / 2). Since 'only zeroes' do compress very well.


    So please do yourself a favour and always follow these steps:

    • Always test your SD card with either F3 or H2testw first to check for counterfeit/broken cards. Always directly after purchase
    • Then use SD Formatter to perform a full device TRIM
    • For satisfying results burn our images only with Etcher (no need to decompress, Etcher will verify the burning process and saves you from some common SD card troubles)

    With USB thumb drives it's basically the same but unfortunately we usually can't make any use of TRIM here so in fact SD cards are the better option compared to USB pendrives. No need to use old and crappy cards. Today insanely fast SD cards compliant to 'A1 app performance class' are avaible. Well, this is even the 1st step: buy a good SD card and not rely on some smelly old card you found in the drawer...


    Well, I didn't address the original question how to clone but just tried to explain the ideal prerequisits that make cloning to compressed device images more easy and that help your SD card living longer.


    Advanced stuff (please skip if already confused by the above):


    My personal take on cloning cards is somewhat special since I have a dedicated SBC for this where a script does the whole job. Cards are read with ddrescue, then I let the script empty caches and compare md5 hashes of block device and image (verify), then the image will be copied to the final destination which is a zlib compressed btrfs. A snapshot is created prior to the copy and the already existing device backup will then be overwritten. With this approach I get all the compression goodness and new device backups only take up the space needed for an incremental update (only changed blocks are now part of the next created snapshot).


    This way the filesystem does the compression job (multithreaded) and also storing just the differences to the last clone. If the SD card dies (ddrescue + md5 verify will tell me unlike dd or WinDiskImager and other tools that blindly believe into they copied correctly) I take the image from latest snapshot and then write it to a new card. Helps keeping write cycles low compared to permanent 'card to card' cloning.

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!