Copy files from a failing disk

From Leo's Notes
Revision as of 23:53, 20 March 2022 by Leo (talk | contribs) (Created page with "When trying to read a file that's stored over bad sectors, you'll encounter 'input/output' errors. In rsync, you'll get a 'failed verification' warning. Rsync will then continue on with the remaining files before attempting to copy the file again. {{Highlight | code = file.mkv 982.58M 100% 30.80MB/s 0:00:30 (xfr#4, to-chk=176/344) WARNING: file.mkv failed verification -- update discarded (will try again). file.mkv 982.58M 100% 31.08MB/s 0:00:3...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
This page was last edited on 20 March 2022, at 23:53.

When trying to read a file that's stored over bad sectors, you'll encounter 'input/output' errors.

In rsync, you'll get a 'failed verification' warning. Rsync will then continue on with the remaining files before attempting to copy the file again.

file.mkv
        982.58M 100%   30.80MB/s    0:00:30 (xfr#4, to-chk=176/344)
WARNING: file.mkv failed verification -- update discarded (will try again).
file.mkv
        982.58M 100%   31.08MB/s    0:00:30 (xfr#5, to-chk=176/344)
rsync: read errors mapping "/mnt/sda/file.mkv": Input/output error (5)
ERROR: file.mkv failed verification -- update discarded.
total: matches=0  hash_hits=0  false_alarms=0 data=1965159605

sent 1.97G bytes  received 29.97K bytes  30.96M bytes/sec
total size is 73.14G  speedup is 37.21
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1189) [sender=3.1.3]

In dmesg, you'll likely see some messages about the failed reads:

[Sun Mar 20 17:36:39 2022] ata1.00: exception Emask 0x0 SAct 0x1800000 SErr 0x0 action 0x0
[Sun Mar 20 17:36:39 2022] ata1.00: irq_stat 0x40000008
[Sun Mar 20 17:36:39 2022] ata1.00: failed command: READ FPDMA QUEUED
[Sun Mar 20 17:36:39 2022] ata1.00: cmd 60/00:b8:00:f5:36/01:00:07:00:00/40 tag 23 ncq dma 131072 in
                                    res 41/40:00:c8:f5:36/00:00:07:00:00/40 Emask 0x409 (media error) <F>
[Sun Mar 20 17:36:39 2022] ata1.00: status: { DRDY ERR }
[Sun Mar 20 17:36:39 2022] ata1.00: error: { UNC }
[Sun Mar 20 17:36:39 2022] ata1.00: configured for UDMA/133
[Sun Mar 20 17:36:39 2022] sd 1:0:0:0: [sda] tag#23 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE cmd_age=2s
[Sun Mar 20 17:36:39 2022] sd 1:0:0:0: [sda] tag#23 Sense Key : Medium Error [current]
[Sun Mar 20 17:36:39 2022] sd 1:0:0:0: [sda] tag#23 Add. Sense: Unrecovered read error - auto reallocate failed
[Sun Mar 20 17:36:39 2022] sd 1:0:0:0: [sda] tag#23 CDB: Read(10) 28 00 07 36 f5 00 00 01 00 00
[Sun Mar 20 17:36:39 2022] blk_update_request: I/O error, dev sda, sector 121042376 op 0x0:(READ) flags 0x80700 phys_seg 2 prio class 0
[Sun Mar 20 17:36:39 2022] ata1: EH complete
[Sun Mar 20 17:36:41 2022] ata1.00: exception Emask 0x0 SAct 0x100 SErr 0x0 action 0x0
[Sun Mar 20 17:36:41 2022] ata1.00: irq_stat 0x40000008
[Sun Mar 20 17:36:41 2022] ata1.00: failed command: READ FPDMA QUEUED
[Sun Mar 20 17:36:41 2022] ata1.00: cmd 60/08:40:c8:f5:36/00:00:07:00:00/40 tag 8 ncq dma 4096 in
                                    res 41/40:00:c8:f5:36/00:00:07:00:00/40 Emask 0x409 (media error) <F>
[Sun Mar 20 17:36:41 2022] ata1.00: status: { DRDY ERR }
[Sun Mar 20 17:36:41 2022] ata1.00: error: { UNC }
[Sun Mar 20 17:36:41 2022] ata1.00: configured for UDMA/133
[Sun Mar 20 17:36:41 2022] sd 1:0:0:0: [sda] tag#8 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE cmd_age=1s
[Sun Mar 20 17:36:41 2022] sd 1:0:0:0: [sda] tag#8 Sense Key : Medium Error [current]
[Sun Mar 20 17:36:41 2022] sd 1:0:0:0: [sda] tag#8 Add. Sense: Unrecovered read error - auto reallocate failed
[Sun Mar 20 17:36:41 2022] sd 1:0:0:0: [sda] tag#8 CDB: Read(10) 28 00 07 36 f5 c8 00 00 08 00
[Sun Mar 20 17:36:41 2022] blk_update_request: I/O error, dev sda, sector 121042376 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 0
[Sun Mar 20 17:36:41 2022] ata1: EH complete

If you need to recover the file despite the read errors, you can use dd using the conv=noerror option. The output file will have the problematic sections will be padded with zeros.

# dd if=broken_file.dat of=/recovery/broken_file.dat conv=noerror,sync status=progress