3

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.

2
  • 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. Jan 26 '12 at 18:41
  • 1
    @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. Feb 6 '12 at 18:26
7

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!

1
  • I would consider step 3 mandatory, not optional.
    – Elder Geek
    May 13 '14 at 3:35
0

Probably you will not be able to access that partition from your ubuntu installation because its being used as swap space and should not be ummounted. You can try using a live cd like parted magic http://partedmagic.com/doku.php?id=start to boot and access your sda2 partition from there. If you didn't use a lot your ubuntu system after the install, probably you still can recover your data in that partition, but also it is very probable that your data was overwritten and lost when the partition was used as swap for your ubuntu system.

You can try using Testdisk from the parted magic live session to recover your ntfs partition

2
  • 2
    Yes, it's swap space, but it can be deactivated with swappoff a and treated like any other partition (see my answer). Jan 26 '12 at 19:18
  • @jmendeth i didn't know about that, very useful tip :)
    – zurdo
    Jan 26 '12 at 21:34
0

I've had the same issue, even worse - I managed to turn into swap one of my NTFS drives and linux /home ext4 partition. Recovering NTFS partition was relatively simple using testdisk following what Alba suggested. Recovering ext4 required some more steps: After recovery using testdisk, gparted of linux-mint live boot drive still considered the home partition to be swap. In testdisk I had to do the following: After selecting disk and partition type, go to Advanced, choose my ext4 partition and choose [Type] in the bottom, change type to "MS Data" and then "ext4", after that there will be a [Superblock] option at the bottom. That gave me a list of superblock locations (backups I guess) like this:

     Partition                  Start        End    Size in sectors



MS Data                614402048  894853119  280451072 [Home]
superblock 0, blocksize=4096 [Home]
superblock 32768, blocksize=4096 [Home]
superblock 98304, blocksize=4096 [Home]
superblock 163840, blocksize=4096 [Home]
superblock 229376, blocksize=4096 [Home]
superblock 294912, blocksize=4096 [Home]
superblock 819200, blocksize=4096 [Home]
superblock 884736, blocksize=4096 [Home]
superblock 1605632, blocksize=4096 [Home]
superblock 2654208, blocksize=4096 [Home]

To repair the filesystem using alternate superblock, run
fsck.ext4 -p -b superblock -B blocksize device

so in a separate terminal tab I ran

fsck.ext4 -p -b 32768 -B 4096 /dev/sda1

And finally gparted saw the drive as an ext4 and not swap, I managed to mount the drive and finally see all my files back

0

I had exactly the same problem and was able to restore the partition, it even booted the Windows as before the accident.

When using testdisk, if there are many partitions and you're not sure which to undelete, what I did was to first find my lost partition that I wanted to recover and undelete it (change type from D to either P or L), then for the rest of the partitions in testdisk - switch type (in my case from D(elete) to P(rimary)) one at a time and testdisk will tell you at the bottom if the structure is OK or bad (in red). It is bad when there are overlapping sectors, so you could also tell that by looking at the start and end sectors for each partition. Also as long as the structure is OK, the undeleted partitions are all in green, when there is a conflict all rows turn white.

Then I restored the boot from the boot backup as described in the last part of the link @Alba provided, and my Windows booted successfully.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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