First of all, I'm going to explain what I think you did, so there aren't any misunderstandings which may lead you to lose your data, so please object if there is anything wrong.
Before installing Ubuntu, the hard disk in question contained two partitions. The first one you call "C", with Windows operating system files on it and a second one you call "D" with personal data. When you installed Ubuntu, you repartitioned your "D" drive to free some space for Ubuntu's root and swap partitions. After doing that, you booted up Windows, where "D" was still displayed but when you wanted to display the partition's contents, it told you is was not formatted. Maybe you rechecked using Windows' disk management tool and noticed a block containing "unallocated space".
Before you take any further actions, I strongly recommend you to stop using the computer/hard disk in question immediately! Every further usage will lead to disk writes you cannot control and may destroy your data forever, so turn it off asap. The first step you should take is to take a full backup of your hard drive to another one if possible. In any case, you should not boot into an installed operating system until the problem is resolved but use a live cd like the one you installed Ubuntu from.
Taking a backup of your hard disk
- Boot from Ubuntu live
- Mount external hard disk (no partition from the internal one!), for example by selecting it inside the file manager
- Remember the path the external data source was mounted to. As I'm not using Ubuntu myself I'm not sure the full path is displayed right there. Do a right-click in free space and select the "Properties"-ish option from there. The full path should be displayed now. I'm going to use it as
/media/usb
- Open Terminal and get root by entering
sudo -s
- Install
ddrescue
by entering apt-get update && apt-get install gddrescue
- Type
fdisk -l
to show hard drives and their partitions. Guess which hard drive is your "broken" one. It should be something like /dev/sda
- Backup
/dev/sdX
by typing ddrescue /dev/sdX /PATH/TO/EXT/HDD/hddimage.img /PATH/TO/EXT/HDD/hddimage.log
- As soon as it's done have a quick look at the created logfile to see if everything went well
You are now ready to try any rescue operations. Before we continue, a quick overview over how that partition thing usually works (may vary a little bit for MBR/GPT and BIOS/UEFI but that's not really relevant here):
- The first few sectors contain the hard disk's MBR. For BIOS systems, this is where the code is stored that gets executed first (usually a part of the boot loader) and the information, where partitions on the hard drive begin). You can then see a partition as a big block on your hard drive containing data.
- Every "big block", aka partition, begins with information about the file system (e.g. NTFS or ext4), which itself stores information about where the single files are that are important to you.
As I see it, there are two possibilities: First is, the Ubuntu partitions were created at the beginning of your data partition. This would be pretty bad as this would have probably overwritten the NTFS structures of your former "D" drive. It basically means it won't be able to recover the exact file names and information about where the files are (which makes the recovering process MUCH more reliable, as then it's mostly a matter of recognizing the data structure and recovering the whole partition at once. The recovering program would need to look for every single file which can be pretty unreliable and often won't work for files which were not saved sequentially but were split up across different regions of the drive.
In case Ubuntu's partitions were created after the NTFS structures it should be way easier to recover at least some of your files.
With the information provided above (please read & understand!) it should now be pretty straight-forward for you to use a tool like TestDisk. You can install it (still, inside your live system!) using sudo apt-get install testdisk
and use it by running sudo testdisk /dev/sdX
. There are some very good guides how to use it on TestDisk's wiki you can find using the link. If it shouldn't be able to recover your whole partition, you could use different tools made for recovering single files instead of partitions. Examples for this are photorec
(installed together with TestDisk, just sudo photorec
) or foremost
. Ubuntu's wiki has some good documentation and guides about data recovery, too, be sure to check it out for further tips.
Please consider reading the answer mentioned in How do I recover my accidentally lost Windows partitions after installing Ubuntu? too. It includes a very detailed description about installing and using TestDisk, together with some very helpful screenshots.