Ubuntu – Can’t restore the gpt data with gdisk

bootdual-bootpartitioningsystem-installationuefi

So I have a pre-instaled windows 7 EFI boot on SSD in GPT

Ubuntu installer couldn't recongize the SSD so I saw that I should try to zap the gpt using gdisk , before doing that I made a backup to a file of the gpt data.

Now that the SSD has no gpt Windows 7 wont boot at all, so I went back to gdisk to restore the gpt data and I am unable

kubuntu@kubuntu:~$ sudo gdisk /dev/sda
GPT fdisk (gdisk) version 0.8.8

Partition table scan: MBR: protective BSD: not present APM: not
present GPT: not present

Creating new GPT entries.

Command (? for help): r

Recovery/transformation command (? for help): l Enter backup filename
to load: gpt_original

Recovery/transformation command (? for help): w

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

Aborting write of new partition table.

Note that before deleting gpt I already had the 33 blocks overlap and Windows 7 booted ok. Is there a way to force gdisk to restore my gpt with my backup?

Best Answer

The overlapping data suggests that you did not have a GPT disk to begin with, but in fact had an MBR disk and were booting in BIOS mode. (One of gdisk's features is that it automatically converts from MBR to GPT when you launch it on an MBR disk.) If I'm right, you can probably restore the MBR as follows:

  1. Launch gdisk, as in your example.
  2. Load the (converted-to) GPT backup data, as in your example.
  3. Type r to enter the recovery & transformation menu.
  4. Type g to convert the GPT data to MBR form (in memory). You'll see a new MBR command prompt.
  5. Type p to view your converted-to-MBR partition table.
  6. Review the output to be sure that all the partitions are present -- none should be listed as omitted in the Status column. You may want to review the FixParts documentation, as FixParts uses this same menu, and the documentation describes the options in more detail.
  7. Once you're satisfied that all your partitions are present and set as they should be, type w to save your changes and exit.

OTOH, if you're positive that the disk was in GPT form and that the computer was booting Windows in EFI mode, then your partition table was simply damaged to begin with. In this case, you may need to delete that final partition and re-create it a little bit smaller to make it fit; gdisk won't let you save a damaged partition table.

Related Question