How TestDisk and the GParted LiveCD saved my deleted partitions

I was messing around with Vmware converter (in windows XP, running from a dual-boot partition), and then I kept getting the following message: “FAILED: Unable to find the system volume, reconfiguration is not possible” at 95% in the reconfiguration step. Apparently the windows ‘System’ drive was not marked as active. This was indeed true, because my linux ext3 boot partition was indicated as the active one in Windows Disk Management console. I didn’t want to use the ‘reconfigure machine’ option to change these properties as explained here, because I would then have to change the SID, Computer Name, etc.

All that glitters…

Forgetting how selfish the Windows OS is concerning disk partitions, I went ahead and used Disk Management console to set the windows partition as ‘Active’. Suddenly, all my logical partitions disappeared (they were all ext3 filesystems), leaving me with four primary partions: root, /usr, ‘unallocated’, and windows XP. I thought they had been hidden from sight.

I went ahead and ran VMware converter again, and this time it was successful. When it came time to boot into linux, I was greeted by grub (which was good), and the linux system began to boot up (which was also good). However, I got errors on the console saying sda5, sda6, sda7 and sda8 could not be mounted. I immediately restarted and booted into windows, went to Disk Management and tried to unset the ‘Active’ flag. Alas, all (the remaining two, that is) of my ext3 partitions now showed up as ‘unknown’, and there was an ever-so-long expanse of disk space labelled ‘unallocated’ where the extended partition used to be. That was when it dawned on me that windows had actually zapped these partitions.

Gone with the Wind(ows)

Could I have lost my 250GB installation of Debian? I almost went insane – there was two weeks worth of development work in there, plus my beloved pictures, not to mention that I’d just spent the past 48 hours downloading over 1.8GB of Debian Wheezy packages and tweaking the system to my heart’s desire. In a frenzy I began to Google on my Blackberry, and three names came up: gparted, testdisk and scalpel.

I remembered testdisk from my days of file recovery from FAT32 drives on crashed Windows 98 computers, but I had no idea there was a linux version of testdisk. I also didn’t know that the GParted LiveCD (which I just happened to have close by) included testdisk as a tool And, in case I couldn’t get my partitions back, there was scalpel to help (painfully) extract my data into another disk. I proceeded to boot into the GParted liveCD, and opted to be dropped into a command prompt. I then ran ‘testdisk’, selected the victim disk.

Testdisk - select the disk to fix


I was presented with the current partitioning table with 3 primary partition and 1 unallocated. I chose ‘Analyse’ to scan for previous versions and voila: there were my partitions – all marked as deleted. Thank you very much, Microsoft. I selected each partition and modified their properties back from ‘D’ (deleted) to ‘P’ or ‘L’ (primary or logical) – this is because I knew the sizes of each partition like the back of my hand, so I remembered what should have been where. Anyway, I chose to save changes and write the now-modified partition table to disk, and was reminded that I needed to reboot. I restarted the computer without the LiveCD, and now I have back my lovely Gnome 3.2 on Debian Wheezy. The first thing I did was to backup my MBR and partition table!

Lessons Learned

I learned 3 things from this experience:

  1. Never, ever, ever edit your partitions with a Microsoft tool, when you have a dual boot setup – this is self explanatory
  2. Always backup your MBR and partition table before you make changes to your partitons – remember Murphy’s Law
  3. I was right to have kept important boot files and system binaries one one partiton and mounted as root – the system will still be (minimally) useful

Related Posts

Unresolved Assembly Reference when Merging Precompiled ASP.NET Assemblies

If you need to merge the output DLLs generated after precompiling an ASP.NET website from Visual Studio 2008 and later, you need to use the ASP.NET merge tool. The location of this tool is a bit tricky, though. The version in the default location is actually the wrong one!

Accessing the VMware BIOS Screen at startup

Fortunately, there is a configuration setting that will give you more time to enter the BIOS screen at startup. It will make the POST screen delay for the specified number of milliseconds.

Reading a Binary XML stream in WCF

If you don’t provide a dictionary to read the XML stream with, you will get a weird and unhelpful exception that says “the input source is not correctly formatted”, and googling around will only bring you to posts telling you that “your client/server endpoints are not matched” or “you need to use the basicHttpBinding”. This is not a binding issue – it’s a deserialization issue that comes up when i make an attempt to inspect the soap messages coming in to (or going out of) my WCF service.

Installing VMware Tools on VMware Player 4.0.2 – Temporary fix

While looking for a fix for the inability of VMware player 4.0.2 to get updated vmware tools (I was getting the error message “Could not find component…

Specifing the bridging network adapter in vmware player 4

For those of you using VMware Player 4 on linux hosts, if you’re not happy with the autobridging for the vmnet0 network, you can choose a specific…

Compile Nvidia Driver 195.36.31 for Debian Squeeze with backported kernel

I’ve been trying to get a backported kernel to work on my installation of Debian Squeeze, but it seems some include files are not included in recent kernel versions. There are also some issues with Kernel version checks in the Nvidia Makefiles.

I finally got it to work by combining information from the Debian Wiki and Paul Goins’ blog at