In order to install Ubuntu (along side with windows on C:/) I had to partition my D:/ disk using Ubuntu installation steps ( which initially contained data in it), so after completing the installation (setting up / and swap), I found out that the rest of the D:/ partition became unallocated space, hence I lost my data. So my question is : is there any way that for me to restore this lost data?

Any help is most appreciated. Thanks


3 Answers 3


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.


When you format a disk, data is removed from that disk. What did you expect?

Restoring a backup would be the best method.

Some people have had results using the datarecovery help using testdisk, but that really depends on what you did to the disk after the installation. The more you use that system, the less likely it is to be able to recover what was formatted.

Otherwise, you can consider that data gone forever.


Just to add something for clarification, usually when you "format a disk" the quick way, the data itself is not erased/destroyed - rather, the partition table where the map to your data was, is.

The more you use your disk after the partition table is erased, the more you are overwriting the previous data, and making it harder to recover.

As was pointed out above, testdisk and other tools can help you rebuild the map to your data - but files like images, audio and videos tend to get messed up.

Not the answer you're looking for? Browse other questions tagged or ask your own question.