59

I have a Toshiba satellite A-200 laptop with a Vista OS on it with 4 NTFS partitions

(C:) Vista 
(D:) Entertainment 
(E:) Work 
(F:) Sources

and I wanted to start using Ubuntu instead. So I tried it first from the live CD and everything was OK and all the partitions were shown and working and so I decided to install Ubuntu to replace Vista on the (C:) drive. After I did that I can no longer find my folders and files on the (D:), (E:), (F:) partitions and the only file system that is shown is one 198 GB although my HDD is 320 GB.

I can't access the lost data on the remaining 120 GB which I hope is still there and not totally lost

I am now working from the live CD but I am unable to install testdisk. Can I recover the Vista partitions by the product recovery CD to get my laptop back to the factory settings? Can I recover the NTFS partitions using a recovery program for Windows or will that make the problem worse?

I need these data badly as I don't have a backup for them.

bain
  • 11,260
Totally newbie
  • 591
  • 1
  • 4
  • 5
  • Which option you selected when installer asked you how to install (should be a screen similar to this)? – Salem Apr 26 '13 at 20:26
  • 2
    I selected the second option Replace windows Vista with Ubuntu – Totally newbie Apr 26 '13 at 20:52
  • 1
    Also read this: http://www.omgubuntu.co.uk/2014/08/ubuntu-installer-bug-wipes-partitions The wording in our installer seems wrong. – Rinzwind Aug 29 '14 at 10:11
  • 11
    DO NOT MAKE ANY CHANGES TO YOUR DRIVE – Elder Geek Feb 26 '15 at 02:30
  • 1
    Using windows recovery or restore will by far make the problem worse unless you just want a factory fresh version of Windows and (quite possibly) absolutely none of your original data. – mchid Apr 08 '15 at 06:24
  • Some more info on Rinzwind's comment: On newer computers you can boot into a different boot mode than the existing operating system is installed on, the bug report in the article was set to fixed but depending on how careless you are you may still get into such a situation. Testdisk should be able to recover data that has not been overwritten or encrypted if it is aware of such situations and can parse MBR as well as GPT partition tables. I guess I should try this out myself once to confirm it. – LiveWireBT Oct 29 '16 at 21:09
  • Test done. Took a 500 GB hard drive with a preinstalled UEFI Windows 10, mounted it in VirtualBox, installed some updates, filled the drive with data up to 30 GB freespace, installed Ubuntu in MBR mode over it. Result: unable to recover any files with testdisk from the NTFS partition after 2 attempts. Might just be my luck though. – LiveWireBT Oct 30 '16 at 20:55

3 Answers3

52

Unfortunately it seems you accidentally partitioned your whole drive replacing your Windows partitions with a single Ubuntu partition.

You will not be able to recover these partitions by restoring Vista with the recovery CD. In fact every write attempt to your hard drive will make things worse as remnants of your data may get more and more overwritten.

  • Encrypted partitions can not be recovered
  • Drives that were part of a Windows "Storage Space/Pool" can not be recovered

You may however be able to recover your partitions with testdisk Install testdisk but you may not be able to recover all of your data. You can temporarily install testdisk on a live session too (however this will then not be a permanent installation).

  • Please have an external drive ready to save your recovered data before you proceed. You can't recover the data on the same drive.

  • Boot your Ubuntu LiveCD ("Try Ubuntu") and then install testdisk by:

    1. Adding the "Universe" repository to your software sources (from Ubuntu system settings > Software & updates)

      Software & Updates

    2. Updating your apt cache in a terminal by first pressing Ctrl+Alt+T and then typing:

      sudo apt update
      
    3. then install testdisk with:

      sudo apt install testdisk
      
  • Mount your external backup drive in the live session (e.g. with Nautilus) to be able to store recovered data later.

  • Follow the concise step by step guide on the Testdisk Wiki which will help you to recover lost partitions.

  • If you are not able to recover from an image of your overwritten drive (this will need an external drive with more than double the free space than your laptop's hard drive) you need to save all your data on an external drive soon after recovery.

  • You will not be able to recover your Windows installation, as this was overwritten by Ubuntu.

  • Only if you fail to recover partitions you may be able to recover single data file using PhotoRec from the TestDisk suite but this will not recover filenames, folder structures or time stamps of your files.

  • Do not use the drive before you were able to recover your lost data.


Copy data from the live system to an external drive

To be able to save our data to an external drive we need to mount both the recovered partitions and the external USB drive in the live environment. The below picture shows how the USB drive will be mounted on insertion (the internal partitions will be mounted on selecting them):

enter image description here

We can then copy & paste (or drag & drop) our rescued files from the internal drive to the external drive (e.g. by opening a separate Nautilus window, or in releases < 13.04 by adding an extra pane with F3 ). From the terminal we can issue:

cp -a /<mountpoint_source>/* /media/ubuntu/<name_destination>

After sucessful copy we need to unmount the drives to avoid data loss. This will be done in Nautilus from a right click context menu or in the terminal:

sudo umount /media/ubuntu/<name>

Copy single files using testdisk

In case we were unable or did not want to recover the partition table we may try to copy selected files or directories with testdisk from the <Advanced> Filesystem Utils menu:

enter image description here

In above example I had selected examples.desktop and rsynctest folder by pressing : . To copy these files we press C for the next menu giving the file hierarchy of our running system. We have to browse to the mountpoint of our external drive (here /media/23GB_USB but this will probably be /media/ubuntu/<name_of_device in your case). The content of our USB is now listed, and can be browsed for deeper directories:

enter image description here

When we press C in the example above our above selected example.desktop, and the folder rsynctest will be copied to the external USB drive.

To verify we had succeeded we can now open Nautilus in our live system and see the content of the rescued files. After we are done, do not forget to unmount the USB drive.

Takkat
  • 142,284
  • i'll try that, but why did it shows only 200 GB out of the 320 GB, doesn't that mean that they are there but it can't see them? – Totally newbie Apr 26 '13 at 21:23
  • i managed to install testdisk and i run it but it only shows the partitions that is already shown in the system with only 200 GB what shall I do now??? – Totally newbie Apr 27 '13 at 12:14
  • i did the deeper search and it found 2 partitions of the 3... Now I need to copy the files to the Usb that i attach to the lap and I need to choose it from the list shown but I don't know how... how can i find it??? Help – Totally newbie Apr 27 '13 at 14:53
  • I did already followed the instructions and I already copied files abd folders to the home.. but now i want to copy them directly to the USB.. so what should I choose to do that? is it media as I found the location for the USB is media/ubuntu – Totally newbie Apr 27 '13 at 15:07
  • I am so so sorry but I am really a totally newbie and i'm now alitle bit confused. now i am at the screen of testdisk that it shows me the list of the folders and files in the partition and i select the ones that i need and i copy them by pressing C letter on my keyboard BTW it told me at the beging that the partition cannot be recovered however i can access the folders :( i'm confused – Totally newbie Apr 27 '13 at 16:00
  • @Totallynewbie: see edit - hope it helps! – Takkat Apr 27 '13 at 17:48
  • Thanks a lot buddy...... I was able to recover almost all the data. – Sumit Kumar Saha Dec 16 '14 at 19:19
  • Should I still copy the data from the disk, reformat the disk and copy the data back to the disk if it was a pure data disk? My external data HDD became raw, so I'm recovering the partition as we speak, but before I go through all the work, is there a reason why I should reformat the disk, or could I leave it as it is after recovering the partition? – Peter Raeves Feb 15 '15 at 20:48
  • 3
    @PeterRaeves: we can't give you a general advice here. Depending on the reason your drive failed the partition layout may be corrupted or not. If all data were recovered after restoring the partitions you may be safe but for very valuable data I would not want to take the risk. I'd copy all data to a drive I know for sure that partitions are o.k. just to be on the safe side. – Takkat Feb 15 '15 at 20:55
  • I had an old Ubuntu installation, and I was trying to update to a recent one (14.04). I accidentally selected the option "Erase entire disk", clicked Next. I soon realized my mistake and did not proceed any further. The disk originally had a separate partition at /data which contained all my files, and it wasn't in NTFS. Will this solution work for me? (See http://askubuntu.com/q/595036/234374) – a06e Mar 10 '15 at 15:35
  • @becko: it will work the same - but files can only be recovered in case they were not overwritten. – Takkat Mar 10 '15 at 16:25
  • I followed the steps mentioned in here but things didn't work out. After I press p to list files, system became non responsive. So next time I used the write option and it asked to reboot so i did; which made the file system unrecognizable by ubuntu and testdisk doesn't show my drive anymore – ares Mar 16 '15 at 17:18
  • 1
    It should be noted that TestDisk won't work even if the NTFS partition has been slightly overwritten. You just need to overwrite the first few MFT entries to make TestDisk unable to recover that. In that case, you need to use proper NTFS reconstruction software. – Andrea Lazzarotto Jul 27 '16 at 13:12
  • hello @Takkat , thanks for detailed answer , I have one more problem here , I don't have external drive , so can i change the partition type detected in deep search from D to L and mount these partitions later ? – Raaghu Feb 28 '17 at 08:41
  • @Raaghu: unfortunately this is not so easy - depending on the damage that occured recovery usually is for a drive rather than for a partition. Any write acces to a broken drive can make things worse. – Takkat Feb 28 '17 at 09:28
23

DON'T CHANGE ANYTHING ON YOUR HARDDRIVE! Don't install any software, updates or anything else, if possible don't even use Ubuntu until you recovered your data. Else, you will render yor data unrecoverable!

Download SystemRescueCd and burn it. Use it to recover your old partition table. After recovering it, copy all data to an external drive. You will probably be able to recover most of your data, although some will likely be lost forever. After copying your data you can safely install Ubuntu over the entire disk. After that, you can create more partitions if you want and copy the data back to your PC.

Keep in mind, that regular backups are always a good thing to have. (Ubuntu has a tool for that, just hit the Windows key and type "backup".

Donarsson
  • 2,709
  • 21
  • 31
  • 3
    Recovery from SystemRescueCD is also done with TestDisk, which is included in this disk. However it may be a bit difficult to download and burn a CD when you should not use your computer's hard disk. – Takkat Apr 26 '13 at 21:35
  • 1
    That's right. It would have do be done on another machine. Your solution seems better. – Donarsson Apr 26 '13 at 21:40
  • 5
    Best solution is to always have a rescue system handy in the drawer ;) – Takkat Apr 26 '13 at 21:42
  • 1
    testdisk is only ~500k to download to any Debian-based live iso / system, and gddrescue is ~100k. I'd be more comfortable with a Ubuntu or Mint live disk and apt-get a few apps than a whole SystemRescueCD that only comes out for emergencies (with sweaty shaking hands! ;-) – Xen2050 Dec 10 '14 at 02:42
3

Since no one provided a GUI alternatives for the terminal impaired Ubuntu users, here is a GUI for Testdisk.

  • Insert your Ubuntu CD/DVD/USB and boot from it

    • At boot-up, select try Ubuntu out.
  • Download qphotorec.

    • Install like so: sudo dpkg -i qphotorec_1.0_all.deb

    • If there are any dependencies issues, run: sudo apt-get -f install

  • After qphotorec installation, execute it, like so: qphotorec or search via the dash, for qphotorec

    • Select the drive you want to recover, and where you want to recover all the data too.
  • Pray to our Human Deity, and hope you get everything back.

Also, let this be a lesson: ALWAYS BACKUP. Always.


QPhotorec is a 32bit application, if you have a 64bit Operating System, you need to install the 32bit libraries, to run QPhotorec:

sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386

Since most IT personnel are lazy - myself included -, I provide you with a one liner, without the 32bit libraries:

cd /tmp/; wget "http://downloads.sourceforge.net/project/crunchyiconthem/QPhotoRec/qphotorec_1.0_all.deb?r=&ts=1443542155&use_mirror=netix" -O qphotorec_1.0_all.deb; sudo dpkg -i qphotorec_1.0_all.deb; sudo apt-get -f install; qphotorec

QPhotorec on Ubuntu, 14.04, Trusty Tahr

blade19899
  • 26,704