How to recover data from NTFS partition that was made into a Swap partition?

8,859

Don't let the panic invade you. Before trying anything, follow this steps:

Note: to open a program, just press Super to open the dash, and search for its name.

  1. Don't turn your computer on. Instead, go get a Ubuntu live-CD and boot with it.
  2. Immediately after it has booted, open a Terminal and disable the swap partition with:

    sudo swapoff -a
    

    It's very important to do that, or your Ubuntu will overwrite the contents of the partition when it gets out of memory.

  3. (Optional) If have an external disk with enough space, save a full copy of your drive on it:

    sudo apt-get install gddrescue
    cd /media/your-external-disk
    ddrescue -v /dev/sd? backup.dd state.log
    

    Be sure to replace the ? with the letter of the damaged drive.
    Run GParted if you don't know which one is it.

  4. Install testdisk with:

    sudo apt-get install testdisk
    

    and then run it with sudo testdisk.

  5. This is the program that may save your bacon!
    Then, just follow these steps very carefully.
    If you're lucky, you will be able to access your original files and restore your partition back!

Share:
8,859

Related videos on Youtube

Raghav Mehta
Author by

Raghav Mehta

Updated on September 18, 2022

Comments

  • Raghav Mehta
    Raghav Mehta over 1 year

    I have extremely important stuff on my windows partition which during the ubuntu 10.10 installation,when it said that I should create something called swap space, I selected it to be a swap space (without even knowing what it actually meant)

    The Grub2 doesn't show up so I don't get a choice to boot Ubuntu or Windows. I don't get my windows partition as a removable device in Ubuntu either. When I go to disk utility and select the sda2 (i.e.. my windows partition) and click edit partition and select HPFS/NTFS for the type and tick bootable and click OK the small processing sign keep on rotating on the bottom right of the sda2 in the chart and after about 10 to 15 minutes it gives an unknown error and thus, I am still unable to use my windows.

    I am even worse than a beginner who doesn't know a thing about Ubuntu so please be patient and help me out.

    • Nitin Venkatesh
      Nitin Venkatesh over 12 years
      Sorry, but I am guessing you lost the data on your Windows partition if you formatted it to a Swap partition. Also you might have lost your chance to recover data if you were trying to format the same partition again and again. Ofcourse I might be wrong, so until a pro comes along and gives you a suggestion to come out of this, sit tight and brace for impact.
    • Alba Mendez
      Alba Mendez over 12 years
      @nitstorm Yes, you might be wrong. Most probably, he has only overwrited the headers of the partition to create a SWAP space and changed its type in the partition table. But its contents may be safe.
  • Alba Mendez
    Alba Mendez over 12 years
    Yes, it's swap space, but it can be deactivated with swappoff a and treated like any other partition (see my answer).
  • Lupa
    Lupa over 12 years
    @jmendeth i didn't know about that, very useful tip :)
  • Elder Geek
    Elder Geek about 10 years
    I would consider step 3 mandatory, not optional.