Linux – How to refresh the magnetic state on a disks with backups

backupdddisklinuxstorage

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?

Best Answer

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.

Related Question