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 installed ubuntu and set my windows 7 partition as the swap.... dumb move obviously. Windows 7 was unable to boot so I reinstalled windows on a completely different partition and The original windows 7 partition isn't recognized.

So I'm back in ubuntu and using disc utility I can see the partition in question and I'm wondering how I can convert it back to nfts with out loosing any of my data from that partition (originally containing windows 7)

I noticed an edit partition option but I can not find an literature on what that does specifically in the department of file preservation.

share|improve this question
add comment

1 Answer 1

You data may still be physically on the disk, but only if Ubuntu haven't actually used the partition as a swap area (if you did not turn the swapping off yet, you need to do this right now although it may already be too late).

When creating a swap area, mkswap command does not actually format or erase the partition, however, it does erase the first block of the partition to make any previous filesystem invisible, and then it writes a swap header (see man mkswap) - which, in total, overrides the first 4096 bytes of the partition.

A useful question: http://superuser.com/questions/172724/what-file-system-is-swap-on-linux

My reading suggests that NTFS header is 16 sectors (8192 bytes) long, so you've only zapped a half of it. Moreover,

When you format an NTFS volume, the format program allocates the first 16 sectors for the $Boot metadata file. First sector, in fact, is a boot sector with a "bootstrap" code and the following 15 sectors are the boot sector's IPL (initial program loader). To increase file system reliability the very last sector an NTFS partition contains a spare copy of the boot sector.

So, basically, you need to somehow copy the last sector of the partition into the very first sector and that should allow OS to see the partition. It won't be bootable, but the data should be accessible.

Googling for "NTFS restore boot sector" finds a program called TestDisk which claims to be able to do what you need.

There's also software called Photorec which can recover files from a damaged partition by scanning the partition and looking for file signatures. It can recover data even from a partition which cannot be accessed by the OS.

share|improve this answer
add comment

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.