Saturday, August 20, 2011

Restoring Lost Hard Drive Partitions With TestDisk

After 6 months of running Windows 7 on my Sony Vaio, I accidentally ran a rogue EXE file while trying to install a driver for an HTC Evo so I could install an Android app on a co-worker's smartphone.

By the next day, my Windows 7 installation was showing some signs of being defeated. By 5pm that Friday, I was no longer able to boot into Windows 7.

To make a long story short, I installed Ubuntu 11.04 after moving all the data from the laptop to an external media drive. Since that time, I have been struggling to get the 11.04 installation running smooth on the laptop.

I installed Linux Mint 11 to see if it would be any better. Since it is based on Ubuntu 11.04, it suffered from the same freezing problems.

After following some advice on the vaio-f11-linux Google Group, I upgraded Mint 11 to the 2.6.39 Kernel. I started with Linux Mint because it wasn't my production OS and all my data was still accessible on the Ubuntu partition. Mint is also based on Ubuntu, so if he kernel upgrade went without problems, I may consider doing the same on Ubuntu. On Mint, with the new kernel, the problem I was facing with the laptop freezing appeared to be resolved.

Because I've been telling my coworkers I'm going back to Windows 7 if this isn't resolved, I went ahead and repartitioned my hard drive and installed Windows 7. Also, I'm facing a problem with my USB Controller, which Sony says can be resolved by updating the BIOS, a task only possible from Windows 7 64 Bit. I left the other operating systems intact and also left room for more Linux OS installs to see if another platform might run better on the Vaio. Even if I move to Windows, I still want to see if I can get a good, stable Linux platform running on the Sony Vaio.

So, I ended up triple booting Ubuntu 11.04, Linux Mint 11, and Windows 7.

However, after recovering Grub2 after the Windows 7 install removed it, I noticed that all of the Logical partitions on the extended partition were missing, and in their place was 1 large unallocated block.

GParted and the Ubuntu Disk Utility both showed the same scenario. I decided to just go ahead and reinstall Mint as all of the steps I did to make it stable were still fresh in my mind.

After getting the live CD loaded, I thought to Google the situation first. I'm glad I did, because it led me to a really cool utility by CGSecurity called TestDisk.

TestDisk 6.12 detected the lost partitions and repaired them, all from the Mint Live CD. After rebooting and running update-grub, I'm now writing this article from my formerly missing Linux Mint 11 installation.

Had it not been for this tool, I'd be spending another weekend installing operating systems.

Basically, if you think you've done something to your hard drive. STOP! Download TestDisk, and see if it can help you rebuild your partition tables or save any lost data.
Google