LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 05-15-2012, 03:22 AM   #1
FLCL
Member
 
Registered: Jan 2009
Posts: 36

Rep: Reputation: 0
Exclamation Wrote over partition- recovery possible?


I was setting up a dual boot and accidentally wrote over my Win7 partition with a boot partition. I tried recovering with TestDisk but that made matters worse, I didn't pay close enough attention to the block size and restored essentially a blank partition table.

Now GParted reads no partition and the entire disk as unallocated space. However, the data is still intact (at least my storage partition) as I was able to boot into a live environment and mount all of the partitions; as well as access the data on a storage partition.

Is there any way to recover my partition table? Can I re-write it manually? I remember fairly accurately what the setup was. I appreciate any help

tl;dr: wrote over Win7 OS partition, TestDisk recovery deleted partition table, can access data off live CD. Possible to recover partition table?

Last edited by FLCL; 05-15-2012 at 03:23 AM.
 
Old 05-15-2012, 03:39 AM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,275

Rep: Reputation: 1028Reputation: 1028Reputation: 1028Reputation: 1028Reputation: 1028Reputation: 1028Reputation: 1028Reputation: 1028
Quote:
Originally Posted by FLCL View Post
Now GParted reads no partition and the entire disk as unallocated space. However, the data is still intact (at least my storage partition) as I was able to boot into a live environment and mount all of the partitions; as well as access the data on a storage partition.

Let's see something like (as root)
Code:
fdisk -l
parted -l
 
Old 05-15-2012, 05:00 AM   #3
masterclassic
Member
 
Registered: Jun 2007
Distribution: Knoppix
Posts: 140

Rep: Reputation: 23
The safer way would be to make a backup copy of the hard drive on another drive, so that you are able to go back in case of problem.
Even a copy of the master boot sector or the partition table data would be useful.
Unfortunately, rewriting the partition table overwrites the old one. There is no backup copy automatically kept on drive.

You can rebuild the partition table if you know exactly the start and size of the partitions. changing something on the partition table with fdisk doean't change the filesystem and partition content it self. So, if the partition content is always on drive, it is probably recoverable.

Testdisk could detect partition entries, if they are still on the drive (however, the first partition start is highly possible to be overwritten by the new boot partition).

You can use
fdisk -lu
(as root) to list the partition table in sector precision.
Take into account that win7 usually creates partitions aligned to MiB as default, instead of the cylinder alignment in older operating systems.

GParted uses parted to detect the partitions. Try to use the latest GParted livecd, nevertheless you can try older versions too. You never know...

If you are able to restore the original partition table, perhaps you can use recovery software to restore (at least partially) the file system content. The MFT of the ntfs file system isn't located on the start of the partition, so it is very probable that it is intact.
If you can't restore the partitions, it is possible to try file recovering with photorec (it tries to recover files by scanning directly on the drive space, even in the case of broken file systems).

Last edited by masterclassic; 05-15-2012 at 05:13 AM.
 
Old 05-15-2012, 03:46 PM   #4
FLCL
Member
 
Registered: Jan 2009
Posts: 36

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by masterclassic View Post
You can rebuild the partition table if you know exactly the start and size of the partitions.
Here is the read-out from fdisk -lu
Code:
Disk /dev/sda: 320.1 GB, 320072933376 bytes

255 heads, 63 sectors/track, 38913 cylinders, total 625142448 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0xb4c83bd7



   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *        2048      206847      102400    7  HPFS/NTFS

Partition 1 does not end on cylinder boundary.

/dev/sda2          206848   307701759   153747456   83  Linux

/dev/sda3       307701760   307910599      104420   83  Linux

/dev/sda4       307910610   625153409   158621400    f  W95 Ext'd (LBA)

/dev/sda5       307910668   328230907    10160120   83  Linux

/dev/sda6       328232960   625139711   148453376    7  HPFS/NTFS
/dev/sda2 is where Windows was installed. Windows still attempts to boot but is unable and gives an error code 0xc000000f (likely due to the partition table and partial overwrite). Should I try using bootrec to try to recover MBR? I should mention that Grub was installed but Linux wasn't (realized this issue and stopped). Thanks
 
Old 05-15-2012, 04:05 PM   #5
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Main: Gentoo Others: What fits the task
Posts: 15,592
Blog Entries: 2

Rep: Reputation: 4046Reputation: 4046Reputation: 4046Reputation: 4046Reputation: 4046Reputation: 4046Reputation: 4046Reputation: 4046Reputation: 4046Reputation: 4046Reputation: 4046
Your Windows install is borked even if there is only a partial overwrite of the system partition. bootrec.exe will not help here. Backup your data and make a fresh install.
 
Old 05-15-2012, 04:18 PM   #6
FLCL
Member
 
Registered: Jan 2009
Posts: 36

Original Poster
Rep: Reputation: 0
Well, it was worth a shot even if I saw it coming lol. Thanks for the assistance everyone
 
Old 05-16-2012, 11:58 AM   #7
masterclassic
Member
 
Registered: Jun 2007
Distribution: Knoppix
Posts: 140

Rep: Reputation: 23
The problem is that the disk content is altered. If just the partition table is damaged, it would be highly possible to recover it with testdisk. If the partition content is changed, chances unfortunately decrease for success.

The boot error comes from the fact that the boot code in the MBR tries to boot from a location where it doesn't find a valid boot loader.
Fixing boot is normally possible with the install dvd of windows, using a boot recovery option. However, if the start of the file system is broken, I can't see how it would be able to repair it.

About recovering files, I could obly think on a bit copy of the disk, to attempt it later.

A last thought: did you try to see if the win7 partition is accessible (readable) from any linux live cd?

Last edited by masterclassic; 05-16-2012 at 12:02 PM.
 
  


Reply

Tags
data recovery, partition recovery, partitiontable


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Wrote to partition while making image file w/ dd: Did I mess it up? vincebs Linux - General 3 06-24-2010 08:18 AM
Installed FC5> Wrote over Ubuntu MBR: How do i add Ubuntu Partition to Grub Loader Free_beer Ubuntu 4 10-02-2006 06:11 PM
Partition and recovery paulsiu Linux - General 1 06-13-2006 12:19 PM
Partition recovery ElVirolo Linux - Hardware 6 07-30-2005 03:25 AM
partition recovery cshaigh Linux - Software 9 08-26-2001 07:09 AM


All times are GMT -5. The time now is 09:16 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration