4

gpt fdisk question

I have a Hitachi drive which got its GPT corrupted, it came out of a Windows 8 computer which is less than a year old. That pretty much guarantees it was in EFI mode correct?

I am trying to recover my GPT file structure on the hitachi 1 terabyte drive. I'm no computer expert, but for a novice I'm pretty proficient and can fix most computer problems and follow clear instructions.

I was trying to fix my son's computer and so I took out his harddrive and tried to reformat it. Instead of the software reformatting the external drive 1 it reformated the internal drive 0, so I lost my OS and C partition.

I have the drive out and hooked up to my laptop to try and repair the file structure.

I have attached my initial findings using GPT fdisk. When I choose option 2 to rebuild GPT it says the partitions overlap.

I am confused on what this means or what the next step is.

I would be appreciative of any help you can offer.

Here is what I get when I run gdisk:

GPT fdisk (gdisk) version 0.8.10

Type device filename, or press <Enter> to exit: 1:
Caution: invalid backup GPT header, but valid main header; regenerating
backup header from main header.

Warning! Read error 0! Misbehavior now likely!
Caution! After loading partitions, the CRC doesn't check out!
Warning! Error 0 reading partition table for CRC check!
Warning! One or more CRCs don't match. You should repair the disk!

Partition table scan:
  MBR: MBR only
  BSD: not present
  APM: not present
  GPT: damaged

Found valid MBR and corrupt GPT. Which do you want to use? (Using the
GPT MAY permit recovery of GPT data.)
 1 - MBR
 2 - GPT
 3 - Create blank GPT

Your answer: 2
Warning! Main partition table overlaps the first partition by 34 blocks!
You will need to delete this partition or resize it in another utility.

Warning! Secondary partition table overlaps the last partition by
15650193771697010572 blocks!
You will need to delete this partition or resize it in another utility.

Command (? for help): e
b       back up GPT data to a file
c       change a partition's name
d       delete a partition
i       show detailed information on a partition
l       list known partition types
n       add a new partition
o       create a new empty GUID partition table (GPT)
p       print the partition table
q       quit without saving changes
r       recovery and transformation options (experts only)
s       sort partitions
t       change a partition's type code
v       verify disk
w       write table to disk and exit
x       extra functionality (experts only)
?       print this menu

Command (? for help): l
0700 Microsoft basic data  0c01 Microsoft reserved    2700 Windows RE
3000 ONIE boot             3001 ONIE config           4100 PowerPC PReP boot
4200 Windows LDM data      4201 Windows LDM metadata  7501 IBM GPFS
7f00 ChromeOS kernel       7f01 ChromeOS root         7f02 ChromeOS reserved
8200 Linux swap            8300 Linux filesystem      8301 Linux reserved
8302 Linux /home           8400 Intel Rapid Start     8e00 Linux LVM
a500 FreeBSD disklabel     a501 FreeBSD boot          a502 FreeBSD swap
a503 FreeBSD UFS           a504 FreeBSD ZFS           a505 FreeBSD Vinum/RAID
a580 Midnight BSD data     a581 Midnight BSD boot     a582 Midnight BSD swap
a583 Midnight BSD UFS      a584 Midnight BSD ZFS      a585 Midnight BSD Vinum
a800 Apple UFS             a901 NetBSD swap           a902 NetBSD FFS
a903 NetBSD LFS            a904 NetBSD concatenated   a905 NetBSD encrypted
a906 NetBSD RAID           ab00 Apple boot            af00 Apple HFS/HFS+
af01 Apple RAID            af02 Apple RAID offline    af03 Apple label
af04 AppleTV recovery      af05 Apple Core Storage    be00 Solaris boot
bf00 Solaris root          bf01 Solaris /usr & Mac Z  bf02 Solaris swap
bf03 Solaris backup        bf04 Solaris /var          bf05 Solaris /home
bf06 Solaris alternate se  bf07 Solaris Reserved 1    bf08 Solaris Reserved 2
bf09 Solaris Reserved 3    bf0a Solaris Reserved 4    bf0b Solaris Reserved 5
c001 HP-UX data            c002 HP-UX service         ea00 Freedesktop $BOOT
eb00 Haiku BFS             ed00 Sony system partitio  ed01 Lenovo system partit
Press the <Enter> key to see more codes:
ef00 EFI System            ef01 MBR partition scheme  ef02 BIOS boot partition
fb00 VMWare VMFS           fb01 VMWare reserved       fc00 VMWare kcore crash p
fd00 Linux RAID

Command (? for help): ?
b       back up GPT data to a file
c       change a partition's name
d       delete a partition
i       show detailed information on a partition
l       list known partition types
n       add a new partition
o       create a new empty GUID partition table (GPT)
p       print the partition table
q       quit without saving changes
r       recovery and transformation options (experts only)
s       sort partitions
t       change a partition's type code
v       verify disk
w       write table to disk and exit
x       extra functionality (experts only)
?       print this menu

Command (? for help):  
  • read this thread to the end http://askubuntu.com/questions/420778/i-need-step-by-step-guidence-to-recover-grub/421226#421226 If you didn't retart your system it's easier. – kenn Mar 11 '15 at 14:23
  • Cannot use fdisk on gpt drives. Do you have important data in last partition. Can you delete the last partition using gdisks advanced tools. Some have been able to delete partition and recreate it when it only overlaps by a few sectors. Post details from sudo gdisk /dev/sda -l or just l in menu you show above. – oldfred Mar 11 '15 at 20:05

3 Answers3

4

GPT fdisk (gdisk) can indeed fix many GPT problems; but the output you've shown is almost useless; you've shown command lists (twice) and the list of partition type codes that gdisk supports, neither of which is unique to your system. Instead, show us what the p and v commands reveal about the disk. You should also read the gdisk documentation on repairing GPT disks.

The gdisk output you've shown that is diagnostic is the first few lines, which suggest you've got a damaged main GPT header but damaged backup; but the (allegedly undamaged) main GPT data structures show ridiculous overlaps that suggest damage here, too. Without seeing the output from p and v, I can't be sure, but this suggests that the main GPT data may be corrupt. It might or might not be possible to fix this. It might also be worth loading the backup data to see what it resembles, as well as to examine the backup data.

In a worst-case scenario, it might be necessary to use TestDisk, as gedelat suggests; but you should hold this as a last-resort recovery method.

Rod Smith
  • 44,284
  • 7
  • 63
  • 105
0

@gadelat, rod smith: "Hash of things" means in that case by using testdisk: The things much mooore worse!

testdisk brings sometimes bad results in guessing parts (especially on disks which were used as Raid/LVM in the past)

try to use at first ALL IN TEST MODE (e.g. -n):

gpart, fsck.ext3 -b <alternate super block> device

etc.

-2

Great tool for fixing this type of problem is utility testdisk. Give it a shot.

gadelat
  • 107
  • TestDisk is useful in some situations, but it's a tool of last resort. It should not be used until other tools have been tried, because it can really make a hash of things in some situations. – Rod Smith Mar 12 '15 at 00:43
  • How exactly it can make a "hash of things" if you use it's backup function first? – gadelat Mar 12 '15 at 07:31