1. Magnetic drive has failed.
  2. I used ddrescue to recover ~85% of it, with a map file, but the rest is borked and continuing to scrub it would take years.
  3. I can return it for a replacement.
  4. I'd like to shred my data first.
  5. When I try to write to it, it works for the first few hundred MB but then starts pouring input/output errors and the drive becomes completely unavailable (/dev/sdd no longer exists).

So is it possible to use the map file from item 2 to write random data only to the portions of the drive that were recoverable and not attempt to write to the bad blocks?

  • Physical destruction is not an option?
    – Panki
    Dec 3, 2020 at 16:00
  • 3
    @Panki not if it's going to be returned under warranty (item 3) Dec 3, 2020 at 16:02

1 Answer 1


The manual gives you an example which is almost exactly what you want:

When ddrescue is invoked with the option --fill-mode it operates in "fill mode", which is different from the default "rescue mode". That is, in "fill mode" ddrescue does not rescue anything. It only fills with data read from infile the blocks of outfile whose status character from mapfile coincides with one of the type characters specified in the argument to --fill-mode.


In fill mode mapfile is updated to allow resumability when interrupted or in case of a crash, but as nothing is being rescued mapfile is not destroyed. The status line is the only part of mapfile that is modified.


Example 2: Wipe only the good sectors, leaving the bad sectors alone. This way, the drive will still test bad (i.e., with unreadable sectors). This is the fastest way of wiping a failing drive, and is especially useful when sending the drive back to the manufacturer for warranty replacement.

ddrescue --fill-mode=+ --force /dev/zero bad_drive mapfile

[emphasis mine]

The only difference is you want to write random data, so /dev/urandom instead of /dev/zero.

  • 2
    Took 6 hours, but drive didn't disconnect!
    – endolith
    Dec 4, 2020 at 0:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .