Today I finally decided to install Windows8 on my main machine. I used to have Windows7 on it and the partition table of the drive in use is a mess resulting in total chaos. It used to be one partition for windows, one for programs/games and one for storage of files. When I decided to install Ubuntu I had to reduce the size of the document partition, and since the partition manager in windows can only shrink volumes at the end point of the partition I chose to shrink it, make a new partition at the end, move my files there, delete the old and then create new partitions for linux next to my windows partition with a lot of spare in the middle. At least that was the theory...
Installation of Ubuntu went nicely but I ended up booting to Windows without having any choice in the matter. This was easily fixes using EasyBCD, and I've mainly used Ubuntu for a while. Windows 7 did not like any of the wifi drivers I gave it for my (old) wifi card, so I kind of didn't care about using it. All students got access to a lot of Microsoft products via DreamSpark, so I decided to replace Windows7 with 8 to play with it.
I deleted the partition belonging to windows7 and had windows 8 up and running short after. When I tried to boot back into Ubuntu (Windows had naturally overwritten the boot sector - shame on you Microsoft!), the whole partition was missing.. It looked like it was merged back into "free space". What to do? I didn't want to reinstall everything.
I found a utility called TestDisk that scans for deleted partitions. I downloaded the 64-bit linux version, extracted the archive and run the testdisk_static program from a liveUSB ubuntu distribution. I have been scanning for about 3 hours now, and I'll hopefully get it all back...
When the program was done reading all the sectors of the disk I got this list of possible partitions. Some of them overlap. I could enter the partition and look at it's files using "p" (and go back with "q"), mark them with (p)rimary, (l)ogical, (e)xtended and (d)eleted with the arrows (left/right) and save the new setup in the master boot record. There can only be 4 primary partitions on a disk, and one of them has to be bootable. If you want more partitions, one of the primary has to be logical and can contain many extended partitions inside of it. The boot partition will have a boot program that can either just start windows (like the one from microsoft) or it can be a link to different operation systems then way linux's Grub does it. Now I just have to fix the dual boot menu.
A note on using the Windows repair tools: See How to Fix Windows 7 When It Fails to Boot for a description.
Yep, as you can see from the last image I got it all back
So did it work? I have to learn more about that some day..