1

Is it possible to save data from a damaged HDD that I still have access to?

Whenever I try to copy the data I see HDD-related errors such as "I/O error", "input/output error".

Currently, the faulty HDD is connected to a USB port.

HISTORY

Last April 19th I was surprised when suddenly my server in which I host a game was disconnected.

At first, I thought it was only an intermittent connection issue that soon would be reestablished.

One hour later the hosting company told me that the HDD was damaged and they would need to replace it. Next, they restarted Linux in recovery mode and advised me to backup all my data.

When attempting to copy data I noticed that some files simply wouldn't be copied.

My whole database size is 5GB.

I could copy most of the tables, and repair the corrupt ones following the manual. (basically: myisamchk -r table_names)

But, there are a few files I can't extract off the faulty hard drive, thus can not repair those tables. The files that I can not extract are .MYD ones (the ones which store the data).

The hosting company offers only paid backup services. I do have a backup, but it's 6 months old. It's MySQL 5.0 because it's legacy software.

I have read https://stackoverflow.com/questions/879176/how-to-recover-mysql-database-from-myd-myi-frm-files already. The tables that I could extract from the hard drive have been repaired, the problem are those that I couldn't.

ATTEMPTS

While the HDD has been damaged, I can still browse the files on it. It's currently connected to a USB port and I'm trying to copy the files I need.

The commands I have tried so far:

hexdump

hexdump table.MYD > dump-table.hex - it could only dump half of the file.

cp

cp source destination copy half of the file and fails:

cp: error reading '/media/usb/usr/local/mysql-5.0.96-linux-x86_64-glibc23/data/DB/Helmet.MYD': Input/output error

dd

dd if=/input of=/output conv=noerror bs=128k - could copy the two halves of the file, but the final file would be corrupted, and thus missing some of the data. Even though I could repair the file with myisamchk -q table, it would lose thousands of records.

One interesting thing about this problem is that only .MYD files seem to have been affected, and that they are damaged in a way that only the first half of the file can be copied, no matter the file size. This means that if a file has 1.8 mb, I can copy 900 kb before the input/output error shows off. I have checked other files, and whenever I found a damaged one, if I attempted to copy it, only half of it would come out. It seems a strange pattern of damage, isn't it?

Two Samples Using DD

  1. SHOULDERS.MYD (input/output error)

root:/mnt/disk1/bugged-tables# dd if=/media/usb/usr/local/mysql-5.0.96-linux-x86_64-glibc23/data/DB/Shoulders.MYD of=/mnt/disk1/bugged-tables/Shoulders conv=noerror bs=128k

dd: error reading '/media/usb/usr/local/mysql-5.0.96-linux-x86_64-glibc23/data/DB/Shoulders.MYD': Input/output error

4+1 records in

4+1 records out

630784 bytes (631 kB, 616 KiB) copied, 8.58983 s, 73.4 kB/s

13+2 records in

13+2 records out

1836628 bytes (1.8 MB, 1.8 MiB) copied, 8.7681 s, 209 kB/s

original size: 1,861,204 bytes

dd file size : 1,836,628 bytes

enter image description here

  1. HELMET.MYD (input/output error)

root:/mnt/disk1/bugged-tables# dd if=/media/usb/usr/local/mysql-5.0.96-linux-x86_64-glibc23/data/DB/Helmet.MYD of=/mnt/disk1/bugged-tables/Helmet conv=noerror bs=128k

dd: error reading '/media/usb/usr/local/mysql-5.0.96-linux-x86_64-glibc23/data/DB/Helmet.MYD': Input/output error

9+1 records in

9+1 records out

1232896 bytes (1.2 MB, 1.2 MiB) copied, 8.54181 s, 144 kB/s

16+2 records in

16+2 records out

original size: 2,316,880 bytes

dd file size : 2,239,056 bytes

2239056 bytes (2.2 MB, 2.1 MiB) copied, 8.62538 s, 260 kB/s

enter image description here

SYSTEM INFORMATION

OS: Ubuntu 20.04 (no-gui)

MySQL: 5.0

HDD: 2x 2TB (no-RAID)

FSCK

root:~# fsck /dev/sda
fsck from util-linux 2.20.1
e2fsck 1.42 (29-Nov-2011)
fsck.ext2: Superblock invalid, trying backup blocks...
fsck.ext2: Bad magic number in super-block while trying to open /dev/sda

The superblock could not be read or does not describe a correct ext2
filesystem. If the device is valid and it really contains an ext2
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
e2fsck -b 8193 <device>

DMESG (when attempting to copy data out of the HDD)

[36729.425176] ata1.00: exception Emask 0x0 SAct 0x600000 SErr 0x0 action 0x0
[36729.425196] ata1.00: irq_stat 0x40000008
[36729.425211] ata1.00: failed command: READ FPDMA QUEUED
[36729.425230] ata1.00: cmd 60/08:a8:60:84:91/00:00:32:00:00/40 tag 21 ncq 4096 in
[36729.425230] res 41/40:08:60:84:91/00:00:32:00:00/00 Emask 0x409 (media error) <F>
[36729.425258] ata1.00: status: { DRDY ERR }
[36729.425268] ata1.00: error: { UNC }
[36729.618379] ata1.00: configured for UDMA/133
[36729.618404] sd 0:0:0:0: [sda]
[36729.618409] Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE
[36729.618414] sd 0:0:0:0: [sda]
[36729.618417] Sense Key : Medium Error [current] [descriptor]
[36729.618424] Descriptor sense data with sense descriptors (in hex):
[36729.618427] 72 03 11 04 00 00 00 0c 00 0a 80 00 00 00 00 00
[36729.618446] 32 91 84 60
[36729.618455] sd 0:0:0:0: [sda]
[36729.618461] Add. Sense: Unrecovered read error - auto reallocate failed
[36729.618466] sd 0:0:0:0: [sda] CDB:
[36729.618469] Read(10): 28 00 32 91 84 60 00 00 08 00
[36729.618485] end_request: I/O error, dev sda, sector 848397408
[36729.618546] ata1: EH complete
[36732.425409] ata1.00: exception Emask 0x0 SAct 0x1000000 SErr 0x0 action 0x0
[36732.425430] ata1.00: irq_stat 0x40000008
[36732.425445] ata1.00: failed command: READ FPDMA QUEUED
[36732.425463] ata1.00: cmd 60/08:c0:60:84:91/00:00:32:00:00/40 tag 24 ncq 4096 in
[36732.425463] res 41/40:08:60:84:91/00:00:32:00:00/00 Emask 0x409 (media error) <F>
[36732.425491] ata1.00: status: { DRDY ERR }
[36732.425502] ata1.00: error: { UNC }
[36732.604135] ata1.00: configured for UDMA/133
[36732.604161] sd 0:0:0:0: [sda]
[36732.604166] Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE
[36732.604171] sd 0:0:0:0: [sda]
[36732.604174] Sense Key : Medium Error [current] [descriptor]
[36732.604180] Descriptor sense data with sense descriptors (in hex):
[36732.604184] 72 03 11 04 00 00 00 0c 00 0a 80 00 00 00 00 00
[36732.604203] 32 91 84 60
[36732.604211] sd 0:0:0:0: [sda]
[36732.604217] Add. Sense: Unrecovered read error - auto reallocate failed
[36732.604223] sd 0:0:0:0: [sda] CDB:
[36732.604226] Read(10): 28 00 32 91 84 60 00 00 08 00
[36732.604242] end_request: I/O error, dev sda, sector 848397408
[36732.604286] ata1: EH complete
0

1 Answer 1

1

Is it possible to save data from a damaged HDD that I still have access to?

I would say it was unlikely and should absolutely not be your first choice.

Hoping to get anything back from such a device is akin to driving your car off a cliff and then hoping that you can just get into it and drive it away again.

I'm sorry to say it but you've found a very painful way to learn this Very Important Lesson:

Any Data that you don't have [at least] two copies of is Data that you don't care about.

Your running Database is your first copy.
The Backups, which you take expressly to handle the situation in which you currently find yourself, are the second (and more).

2
  • Do you think a professional data recovery company can help? Apr 29, 2021 at 16:57
  • Possibly, but remember that you're still in "My car fell off a cliff; can it be fixed?" country. An insurance company would write off your car on the spot. A /good/ recovery company might well do the same to your disk (and a not-so-good recovery company might take [a lot of] money from you and /then/ do the same). YMMV.
    – Phill W.
    Apr 30, 2021 at 12:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.