I have an old dying hard drive with loads of faulty sectors that I'm trying to save as much data from as I can (before ultimately throwing it out). Using ddrescue
on my laptop on macOS did wonders, I was able to save about 95% of data from the drive, but scraping the last bits around the bad sectors is very slow since the -d
option (direct disk access bypassing the kernel cache) of ddrescue
is not available on macOS.
For this reason, I resorted to using my old RasperryPi 3b with Ubuntu 20.04 LTS and just let ddrescue
run on there for a couple of days to scrape the last bits of data from the drive.
However, when I connect the drive to the RPi, I can't use it at all. It shows up in lsblk
with the correct size, but any read operation on the drive just freezes. After connecting, the drive spins up, then, after a couple of seconds, there is a noticable click (which I assume is the head of the HDD snapping back). This sound repeats every 10-25 seconds and AFAIK is a typical sign of a dying drive. When I connect the drive to my mac however there are no clicks and the non-bad-areas are perfectly readable.
I checked the syslog and it shows some read errors on various sectors on the disk, which strikes me as odd, since I never mounted the disk in the first place (and don't plan to either, ddrescue recommends to not even mount the drive to cause as little potential damage as possible).
This is the syslog after I connected the drive, waited for exactly five clicks, and then disconnected the drive again:
Oct 23 17:46:34 qtpi kernel: [ 681.381739] usb 1-1.2: new high-speed USB device number 4 using dwc_otg
Oct 23 17:46:35 qtpi kernel: [ 681.524105] usb 1-1.2: New USB device found, idVendor=174c, idProduct=55aa, bcdDevice= 1.00
Oct 23 17:46:35 qtpi kernel: [ 681.524123] usb 1-1.2: New USB device strings: Mfr=2, Product=3, SerialNumber=1
Oct 23 17:46:35 qtpi kernel: [ 681.524138] usb 1-1.2: Product: ASMT1051
Oct 23 17:46:35 qtpi kernel: [ 681.524152] usb 1-1.2: Manufacturer: asmedia
Oct 23 17:46:35 qtpi kernel: [ 681.524166] usb 1-1.2: SerialNumber: 123456789012
Oct 23 17:46:35 qtpi kernel: [ 681.592932] usb 1-1.2: UAS is blacklisted for this device, using usb-storage instead
Oct 23 17:46:35 qtpi kernel: [ 681.592946] usb-storage 1-1.2:1.0: USB Mass Storage device detected
Oct 23 17:46:35 qtpi kernel: [ 681.598080] usb-storage 1-1.2:1.0: Quirks match for vid 174c pid 55aa: 400000
Oct 23 17:46:35 qtpi kernel: [ 681.598254] scsi host0: usb-storage 1-1.2:1.0
Oct 23 17:46:35 qtpi kernel: [ 681.598774] usbcore: registered new interface driver usb-storage
Oct 23 17:46:35 qtpi kernel: [ 681.613963] usbcore: registered new interface driver uas
Oct 23 17:46:36 qtpi kernel: [ 682.630848] scsi 0:0:0:0: Direct-Access ASMT 2105 0 PQ: 0 ANSI: 6
Oct 23 17:46:36 qtpi kernel: [ 682.632467] sd 0:0:0:0: Attached scsi generic sg0 type 0
Oct 23 17:46:36 qtpi kernel: [ 682.635097] sd 0:0:0:0: [sda] Spinning up disk...
Oct 23 17:46:51 qtpi kernel: [ 683.653711] ...............ready
Oct 23 17:46:58 qtpi kernel: [ 704.774566] sd 0:0:0:0: [sda] 586114704 512-byte logical blocks: (300 GB/279 GiB)
Oct 23 17:46:58 qtpi kernel: [ 704.775233] sd 0:0:0:0: [sda] Write Protect is off
Oct 23 17:46:58 qtpi kernel: [ 704.775252] sd 0:0:0:0: [sda] Mode Sense: 43 00 00 00
Oct 23 17:46:58 qtpi kernel: [ 704.775891] sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
Oct 23 17:46:58 qtpi kernel: [ 704.822380] sda: sda1
Oct 23 17:46:58 qtpi multipath: sda: can't store path info
Oct 23 17:47:12 qtpi kernel: [ 718.781052] sd 0:0:0:0: [sda] Attached SCSI disk
Oct 23 17:47:44 qtpi kernel: [ 750.657944] usb 1-1.2: reset high-speed USB device number 4 using dwc_otg
Oct 23 17:47:44 qtpi kernel: [ 750.803479] sd 0:0:0:0: [sda] tag#0 FAILED Result: hostbyte=DID_TIME_OUT driverbyte=DRIVER_OK
Oct 23 17:47:44 qtpi kernel: [ 750.803524] sd 0:0:0:0: [sda] tag#0 CDB: Read(10) 28 00 00 00 00 08 00 00 08 00
Oct 23 17:47:44 qtpi kernel: [ 750.803547] blk_update_request: I/O error, dev sda, sector 8 op 0x0:(READ) flags 0x80700 phys_seg 1 prio class 0
Oct 23 17:47:58 qtpi systemd-udevd[900]: sda: Worker [1977] processing SEQNUM=5385 is taking a long time
Oct 23 17:48:05 qtpi kernel: [ 771.966758] sd 0:0:0:0: [sda] tag#0 FAILED Result: hostbyte=DID_ERROR driverbyte=DRIVER_OK
Oct 23 17:48:05 qtpi kernel: [ 771.966784] sd 0:0:0:0: [sda] tag#0 CDB: Read(10) 28 00 22 ef 66 88 00 00 01 00
Oct 23 17:48:05 qtpi kernel: [ 771.966808] blk_update_request: I/O error, dev sda, sector 586114696 op 0x0:(READ) flags 0x80700 phys_seg 1 prio class 0
Oct 23 17:48:19 qtpi kernel: [ 785.798862] sd 0:0:0:0: [sda] tag#0 FAILED Result: hostbyte=DID_ERROR driverbyte=DRIVER_OK
Oct 23 17:48:19 qtpi kernel: [ 785.798888] sd 0:0:0:0: [sda] tag#0 CDB: Read(10) 28 00 00 00 00 40 00 00 08 00
Oct 23 17:48:19 qtpi kernel: [ 785.798913] blk_update_request: I/O error, dev sda, sector 64 op 0x0:(READ) flags 0x80700 phys_seg 1 prio class 0
Oct 23 17:48:28 qtpi kernel: [ 795.238641] sd 0:0:0:0: [sda] tag#0 FAILED Result: hostbyte=DID_ERROR driverbyte=DRIVER_OK
Oct 23 17:48:28 qtpi kernel: [ 795.238667] sd 0:0:0:0: [sda] tag#0 CDB: Read(10) 28 00 00 00 00 80 00 00 08 00
Oct 23 17:48:28 qtpi kernel: [ 795.238692] blk_update_request: I/O error, dev sda, sector 128 op 0x0:(READ) flags 0x80700 phys_seg 1 prio class 0
Oct 23 17:48:28 qtpi kernel: [ 795.238864] usb 1-1.2: USB disconnect, device number 4
Oct 23 17:48:28 qtpi kernel: [ 795.252762] sd 0:0:0:0: [sda] Synchronizing SCSI cache
Oct 23 17:48:28 qtpi kernel: [ 795.258161] blk_update_request: I/O error, dev sda, sector 128 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 0
Oct 23 17:48:28 qtpi kernel: [ 795.268556] Buffer I/O error on dev sda, logical block 16, async page read
Oct 23 17:48:28 qtpi kernel: [ 795.275921] sd 0:0:0:0: [sda] Synchronize Cache(10) failed: Result: hostbyte=DID_NO_CONNECT driverbyte=DRIVER_OK
Oct 23 17:48:28 qtpi multipathd[1497]: uevent trigger error
Oct 23 17:48:29 qtpi multipathd[1497]: sda: path already removed
According to the log, read operations are being done on multiple sectors (8, 64, 128 and 586114696), though I don't understand why these reads are being done in the first place. Sectors 8, 64 and 128 are definitely readable on my mac though, the first bad sector does not appear before around the 350MB mark. Each read error seems to correspond to one click. What could be the cause of this behaviour? How can I fix this?
As it is so often with the RPi, it was a power consumption problem. After I put a powered USB hub in between the ATA-to-USB adapter of the drive (which already has its own power supply, which made me assume I would not need another power adapter) and the rpi, everything works fine.
Thanks to @danzel for having the right intuition.