I was preparing to move data from my old PC to the new one. Just wanted to backup one of my NVMe drives but when I tried standard dd, it failed:

root@box:~# dd if=/dev/nvme1n1 of=/storage/backup/disk.img obs=1M
dd: error reading '/dev/nvme1n1': Input/output error
...

It was my second drive, which I do not care that much but still wanted to make a backup so I could restore what’s possible on new system. I started looking for option to force dd to skip problematic bytes/blocks - whatever possible - and that’s how I found ddrescue1. I heard about it, but I didn’t had occasion to use it before.

root@box:~# ddrescue -f -n /dev/nvme1n1 /storage/backup/file.img /storage/backup/file.log
GNU ddrescue 1.27
Press Ctrl-C to interrupt
     ipos:    1024 GB, non-trimmed:   233472 B,  current rate:  33996 kB/s
     opos:    1024 GB, non-scraped:        0 B,  average rate:    258 MB/s
non-tried:   92602 kB,  bad-sector:        0 B,    error rate:   16384 B/s
  rescued:    1024 GB,   bad areas:        0,        run time:  1h  6m  4s
pct rescued:   99.99%, read errors:        9,  remaining time:          1s
                              time since last successful read:          0s
Copying non-tried blocks... Pass 1 (forwards)
     ipos:  856031 kB, non-trimmed:   385024 B,  current rate:  10264 kB/s
     opos:  856031 kB, non-scraped:        0 B,  average rate:    258 MB/s
non-tried:    6619 kB,  bad-sector:        0 B,    error rate:   24576 B/s
  rescued:    1024 GB,   bad areas:        0,        run time:  1h  6m  6s
pct rescued:   99.99%, read errors:       13,  remaining time:          1s
                              time since last successful read:          0s
Copying non-tried blocks... Pass 2 (backwards)
     ipos:  917962 kB, non-trimmed:   471040 B,  current rate:  60645 kB/s
     opos:  917962 kB, non-scraped:        0 B,  average rate:    258 MB/s
non-tried:   393216 B,  bad-sector:        0 B,    error rate:    106 kB/s
  rescued:    1024 GB,   bad areas:        0,        run time:  1h  6m  7s
pct rescued:   99.99%, read errors:       15,  remaining time:          1s
                              time since last successful read:          0s
Copying non-tried blocks... Pass 4 (backwards)
     ipos:    1024 GB, non-trimmed:   577536 B,  current rate:  60645 kB/s
     opos:    1024 GB, non-scraped:        0 B,  average rate:    258 MB/s
non-tried:        0 B,  bad-sector:        0 B,    error rate:    106 kB/s
  rescued:    1024 GB,   bad areas:        0,        run time:  1h  6m  7s
pct rescued:   99.99%, read errors:       19,  remaining time:          1s
                              time since last successful read:          0s
Copying non-tried blocks... Pass 5 (forwards)
     ipos:    1024 GB, non-trimmed:        0 B,  current rate:   81920 B/s
     opos:    1024 GB, non-scraped:   233472 B,  average rate:    258 MB/s
non-tried:        0 B,  bad-sector:    16384 B,    error rate:    5632 B/s
  rescued:    1024 GB,   bad areas:       32,        run time:  1h  6m  8s
pct rescued:   99.99%, read errors:       51,  remaining time:          1s
                              time since last successful read:         n/a
Trimming failed blocks... (forwards)
Finished

Now I had image. It wasn’t fully correct because of failed reads, but at least I didn’t need to restart dd multiple times. I was able to fix filesystem with fsck, then I had to reinstall few packages to recreate broken files and that’s it.


Enjoyed? Buy Me a Coffee at ko-fi.com