Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have a 1 TB external harddisk where I recently installed Ubuntu onto. Before I had some backups there which I didn't want to lose. Therefore I created a new partition for Ubuntu. During this process I somehow must have changed the type of the backup partition from ext4 to swap (although I can't remember in doing so, but this is what gparted shows me). This new swap partition has never been used by the newly installed Ubuntu which has its own swap partition. Although I think chances are bad: Is there any way to get my data back from my backup (now swap) partition?

To clarify the situation, here's the current partition table of the device:

     Partition                  Start        End    Size in sectors
 1 * Linux Swap               0  32 33 12157 195 58  195312500
 2 E extended             12157 214 24 47791 227 52  572461058
 5 L Linux Swap           12157 214 26 12534 172 54    6053888
   X extended             12534 172 55 17397 188  7   78125056
 6 L Linux                12534 205 24 17397 188  7   78123008
   X extended             17397 188  8 47791 227 52  488282112
 7 L Linux                17397 220 40 47791 227 52  488280064
share|improve this question
1  
There might be a few options. Right now, though, what's most important is not to mount the partition until someone has posted a reliable solution. –  ændrük Dec 15 '10 at 22:44
    
Thanks for the advice, won't touch the thing unless I'm absolutely (i.e 99%) sure what I'm doing^^ –  ubuntudroid Dec 15 '10 at 23:30

2 Answers 2

If what you say above is 100% sure then use testdisk.

  1. Install it: aptitude install testdisk
  2. Run it and point the console interactive to the partition that you are sure it is the one you had before.
  3. If there has been no changes then you should have a big chance of recovering everything.
share|improve this answer
    
Just started testdisk and it came up with asking me for the partition table type. There are the following options: Intel, EFI, Mac, None, Sun and XBox. Looking at the device information at gparted it tells me, that the partition table is msdos?! So Intel (being described as "Intel/PC partition" in testdisk) would be the right one? –  ubuntudroid Dec 15 '10 at 23:25
    
Sadly testdisk couldn't recover the old partition - it just showed up as a swap partition :( But thanks for the suggestion! It was worth a try. –  ubuntudroid Dec 16 '10 at 12:58

If the partion was never used, it is totally recoverable because the data is untouched and the partition size is also kept, you just just use fdisk and change the partition type back to ext:

sudo fdisk device
Command (m for help): t
Partition number (1-8): your partition number
Hex code (type L to list codes): 83

However the "I somehow must have changed the type of the backup partition from ext4 to swap" sounds more like that you have deleted/recreate the partition, the installer does not provide a simple way to modify partition types. testdisk might still help but I wouldn't expect a full recovery.

share|improve this answer
1  
Yes, type is a sneaky word when talking about partitions. If only the type was all that had changed... –  ændrük Dec 16 '10 at 1:35
    
Did as you recommended, but gparted still shows the partition as linux-swap :( Is it maybe because its at the beginning of the harddisk and Linux tries to use it as swap therefore? To clarify the whole thing I added a harddisk dump to the question. –  ubuntudroid Dec 16 '10 at 10:34
    
Just to clarify, did you set the partition type from the Ubuntu installer ? If you did, besides changing the partition type (equivalent to what you can do with fdisk "t") not only the type was change but also an mkswap was performed, which partially writes to the partition data space. If this was the case testdisk is really your best choice, full recovery is not possible. –  João Pinto Dec 16 '10 at 11:52
    
As stated in the thread started by CYREX testdisk wasn't able to recover the partition. Seems my backups are gone... I just hope, that I won't need them in the near future ;) –  ubuntudroid Dec 16 '10 at 12:59
    
I agree with what Joao says about "f the partion was never used, it is totally recoverable because the data is untouched and the partition size is also kept" there are only small cases where a partition format would change the information in it. Maybe your swap was the one that was active when you were using the PC at least for a moment. –  Luis Alvarado Dec 16 '10 at 15:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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