TestDisk — this month’s Useful Utility
TestDisk is a utility, available for most common operating systems, for recovering lost partitions and making non-booting disks bootable again. And it works! And it is easy. It saved the external hard-drive on my digital set top box, and all the files therein. It apparently does a bunch of other stuff too.
For a full list of features I refer you to the website above, but the most impressive thing about it is how easy and fast it is. I had a USB hard drive that we use along with a digital set top box, and one day the USB cord was pulled out and pushed back in in rapid succession, while the thing was operating, and the net result was that the set top box could not see the drive any more. True.
I plugged it into a Windows 10 netbook — no go. I plugged it into my Debian Linux box and it did not show up in Nautilus. So I fired up GParted, and sure enough it found the USB drive, under /dev/sdi, but it thought the whole thing was unallocated space, suggestion something weird had happened to the partition information. Now, GParted has an option (it might be under ‘Tools’ or something) to run gpart, to try to figure out what’s happened, see if there’s something there to recover, but it found nothing. To be fair, I did curtail the run after about half an hour.
Then I did a quick web search and found something called ‘TestDisk‘ being referred to.
I typed in my command line two commands — one to install the program and one to run it. I’m running Debian old stable, and it comes with the slightly old version 6.13, but that seemed to do the job fine. I felt no need to install the latest version, though I suppose I could have.
$ sudo apt-get install testdisk $ testdisk /dev/sdi
then it gave me a simple and clear text-based interface that I could step through using arrow keys and Enter (if the USB HD had contained really valuable data, I would have used dd or some disk imaging tool similar to make an exact copy of it and worked on that, but…). I basically just kept selecting ‘next’ until it got to a screen where I could write the new partition table to the external HD. Since it was an external drive I did not even need to run TestDisk as superuser, which means I did not have to worry about toasting my computer’s hard drive, /dev/sda in my case.
Then I rebooted (whether I needed to or not — I just followed the instructions) and lo and behold all the files were there.
I even made a donation to the project.