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

Leave a comment