8

I have a couple of large disks with backup/archive material on them. They're ext4. Regarding the ones of those that will be stored for a couple of years without reading the whole disc again I've been thinking of a way to refresh the disks magnetic state. Shelf life of drives seems to be a matter of debate everywhere I've been looking for an answer, but it seems after a couple of years (say 5 or so) of storage it would be wise to refresh the data in some way (?)

I've seen this suggested:

dd if=/dev/sda of=/dev/sda

Is it safe? Is it useful?

What I'm looking to do is another thing than a fsck or a dd if=/dev/sda of=/dev/null, both of which will probably discover existing magnetic drop outs on the disk.

What I want to do is to refresh the magnetic data before the magnetic charges on the disk lowers below a readable level. How can I do this?

8

Generally you can't really refresh the whole disk without reading/writing all of it. fsck is unlikely to provide what you need - it works with the file system not the underlying device hence it mostly just scans file system meta data (inodes and other file system structures).

badblocks -n might be an option to dd if=X of=X. In any case you probably want to use large blocks to speed things up (for dd something like bs=16M, for badblocks this would read -b 16777216, or -b $((1<<24)) in reasonable shells). You'll probably also want to use conv=fsync with dd.

As for the safety of dd with the same input and output device - it reads block from input and writes it to output, so it should be safe (I have re-encrypted an encrypted partition like this on several occasions, by creating loop devices with the same underlying device and different passwords and then dd'ing from one to the other) - at least for some types of physical media: for example with shingled drives it is definitely not obvious to me, that it is 100% failure-proof.

  • Thanks for your answer! So conv=fsync does "physically write output file data and meta data before finishing", what does this mean? Is it safer or why would I use it? – PetaspeedBeaver Jun 12 '13 at 8:32
  • 1
    I would expect it to make sure that all kernel caches are flushed to the media before exiting. Since you are just rewriting the same data it actually shouldn't matter that much. It just ensures, that when dd finishes you can pull the plug out (well there may be a cache in the HDD, but that's out of the jurisdisdiction of the software). – peterph Jun 12 '13 at 9:29
  • So in summary, the full dd command should be something like dd if=/dev/sda of=/dev/sda bs=16M conv=fsync plus maybe also status=progress to show progress. This will take a while, depending on the size and speed of the drive. I presume that cancelling this mid-process with e.g. Ctrl+C is safe? – Martin Spacek Nov 23 '18 at 14:18
  • 1
    Yes, interrupting the whole process in any way should in theory be safe. At least for a non-shingled spinning magnetic drive - this is an area where the exact physical principle and technology used do matter. – peterph Nov 25 '18 at 23:22
1

I dont know of a way to do this with any native tools from within a *nix, but something I have done for quite a few years is run a product called Spinrite from GRC.com.

It has a few modes one of them is for refreshing the surface/data by running thru every sector inverting the state of each bit a few times and then putting it back to the way it was.

I run it like this a few times a year on my drives, and not that I want to say this out loud, but I feel I have very few problems with my hard drives, and there are quite a few.

It does cost around $80-90 IIRC but that cost is all relative depending on what you think your data is worth to you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.