ithardwarerestorehddbackup
~5 min (871 words)

How to restore a hard disk when it's not completely broken

Photo showing an opened hard disk close up

If you're still using HDDs (Hard disks) you might run into some issues with it over time. It might even fail completely or just give you some corrupted data. Here's how I restored a hard disk's data for a friend, recently.


How to recognize a broken hard disk

A hard disk can fail in many ways. I'm not an expert in hard disks and data recovery, but I had my fair share of failing disks and recovering data from it. So, basic knowledge about that stuff exists.

Breaking heads

Ok, this sounded funny... So I couldn't resist.

Either the head for reading/writing data breaks or its mechanics for moving it fail (which leads to funny sounds from your hard disk). In this case your best option is to either try to safe as many data as you can immediately or, if the data is too important let a lab do the job of repairing the head. Which is, in many cases, really (and I mean REALLY) expensive.

Why? Because, every disk usage from now on will destroy the disk a bit more (i.e. the head can scratch on the platters). Given, the head can move at all anymore, of course.

Bad sectors

Or, some sectors on the disks fail. This is normal due to wear and tear the older the HDD gets. Most of it can be fixed by some Software logic (either the HDD's firmware or the Filesystem).

But! There might be a fast-growing number of bad sectors. That's a hint for degrading disks and should lead to a fast replacement.

Corrupted Firmware or Controller

Then there's corrupted firmware: Sometimes the firmware controlling or even the controller chip(s) itself can fail. In this case, very often, you'll lose access to the disk pretty fast.

What else?

Sometimes you get errors, i.e. corrupt data or the disk can't be found. This might also be caused by a cable defect. So check the cables. A cable might just not be fully connected. Or it broke. Try with another one.

How to prevent hard disk failures

There really is only one way: Do backups, do them regularly and for the important data do at least an offsite and onsite backup. For example one at home and one online. Two different locations (i.e. office and basement) are a good start as well.

Remember: Your hard disk will fail, eventually!

How to restore a broken hard disk's data

So, as mentioned earlier, I had some fun restoring a friend's external hard disk not so long ago. In contrast to how it sounded at first the disk still worked. But there were definitely issues. Windows couldn't find the disk anymore, at least most of the time. So I checked with another cable and tried using it without the device's internal USB Controller. No luck.

So I tried with Linux. There I could get access to the disk. But only with huge lags to the 2 partitions.

After checking the S.M.A.R.T via smartctl data I concluded there were no obvious errors.

So, next I tried rewriting the partition table and repairing the MBR via TestDisk. Which worked. Now having access to the partitions without major lags.

Still no luck with Windows after that, though.

Having access to the filesystem via Linux now, I found some corrupt and missing files.

So I needed another tool: ddrescue. With ddrescue you can restore deleted and sometimes corrupt (via filesystem) files.
Using the command ddrescue /dev/sdx1 /path/to/imagefile.img I could write all the potential data to an image file. Be careful here, depending on the disk or partition size the resulting file is going to be (very) large. For that reason you might need a big disk for storing the image.

Well, that worked. Now I got a new HDD and started copying the rescued data back to the new disk (using rsync). That's where the 'I'm not an expert' part came in. Somehow I (or ddrescue and I didn't know how to prevent this) mixed up the file encoding. All rescued files were formatted as utf-32-le which mixed up the filenames with special chars (my friend is German, so yeah), therefore I couldn't copy them all.

Luckily, there's a way to fix that as well. Mounting the image into a loop device and changing the encoding via convmv -f utf-32-le -t utf-8 fixed the names, and so I started copying, again.

That took a while, of course.

After finishing the backup and testing the new HDD in windows everything went fine. Well, I had to repair the MBR via NTFS tools on Windows, again, at first. But this time it worked and my friend can now use her data, again.



Image Attribution
Article Picture from Denny Müller auf Unsplash