49

After successfully installing a dual boot environment, adding Ubuntu 13.10 to a preinstalled Windows 8 configuration I decided to increase the unallocated SSD disk space after reading about the benefits of over-provisioning. So, using miniTools Partition Wizard in Windows, I shrunk the NTFS Windows partition somewhat. That seem to have completed successfully. However, when I boot up Linux and launch GParted, it gives the following error message at startup:

The backup GPT table is corrupt, but the primary appears OK, so that will be used.

Everything seems fine and dandy with the system, but I am worried that I will have a problem should the main GPT table become corrupt for some reason.

I have used gdisk to backup the GPT table to a file, but is there a way to create a new backup GPT table?

2
  • I would NOT recommend using the MiniTool software (used over the years mostly successfully). I recently attempted to partition an SD Card with the software and wound up with a real annoying GPT Partition Table that needed major fixing (or 5-10 mins of Googling but annoying all the same). Stick with Linux if you can and use either gdisk or fdisk to create your partition table. Nov 10, 2018 at 15:33
  • I fixed my disk using these commands: 1) $ sudo gdisk /dev/sda 2) Command (? for help): x 3) Expert command (? for help): e 4) Expert command (? for help): m (To return to the main menu) 5) Command (? for help): r 6) Recovery/transformation command (? for help): d 7) Expert command (? for help): m (To return to the main menu) 8) Command (? for help): w 9) Finally, reboot Jun 23, 2022 at 20:57

4 Answers 4

62

Best to backup partition table first, just in case changes are not correct. Then it is possible to restore old partition table. If drive is sda & save to another drive:

sudo sfdisk -d /dev/sda > PT_sda.txt

Use gdisk and verify partitions are correct with p, and use w to write the partition table. If not correct just use q to quit. That should update primary, backup & protective MBR.

sudo gdisk /dev/sda
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

Be sure to see comment below by Rod Smith, he is author of gdisk at his rodbooks site.

9
  • 3
    Thanks, that fixed the issue! Now to another question, is it possible to merge two separate blocks of unallocated space and in that case, should I?
    – tomoqv
    Dec 6, 2013 at 7:05
  • 11
    Note that gdisk also has a v command that should turn up details about most GPT problems. Also, this page describes gdisk's repairing options. As to merging two separate blocks of unallocated space, that's done in GParted or the like by moving intervening partition(s). This is a risky operation, so do it only if necessary. Alternatively, you could create two partitions and use LVM to create a logical volume that would span both partitions, even though they're non-contiguous.
    – Rod Smith
    Dec 6, 2013 at 18:13
  • 2
    CAREFUL - my disks were part of a software raid array. This command changed the partition type from "Linux raid autodetect" to "Linux filesystem" and now my raid array superblocks are missing. (I have a backup). Jan 3, 2018 at 18:22
  • 2
    I know this is an old question and I have the same problem, but none of the gdisk options successfully repaired the GPT. I get an error saying the backup GPT is corrupt and no matter what I have done, I have not been able to fix this. I am currently using TestDisk to try to recover the device, but I have low hopes that this will work. I am using a 250Gb MicroSD card. Oct 17, 2019 at 15:26
  • 2
    Best to backup current partition table before trying to make changes: sudo sfdisk -d /dev/sda > PT_sda.txt Belst to then start your own question, posting your details.
    – oldfred
    Oct 17, 2019 at 18:10
7

The simplest way to fix backup GPT is:

sgdisk -e <target-device>

for example:

sgdisk -e /dev/sda

As documented in the manual the -e option:

-e, --move-second-header: Move backup GPT data structures to the end of the disk. Use this option if you've added disks to a RAID array, thus creating a virtual disk with space that follows the backup GPT data structures. This command moves the backup GPT data structures to the end of the disk, where they belong.

5
  • For me, this had no effect. Jun 7, 2022 at 12:52
  • @RayWoodcock you may have to do that as root user or use sudo if needed.
    – Diego
    Jun 8, 2022 at 9:34
  • -bash: sgdisk: command not found
    – CS QGB
    Dec 18, 2022 at 7:10
  • @CSQGB sgdisk is part of the GPT fdisk (aka gdisk) package, so you're missing that package and you should install it.
    – Diego
    Dec 20, 2022 at 8:38
  • Worked for me , thank you!
    – Aaron
    Jan 20, 2023 at 8:23
2

Not exactly sure, but when I have two disks part of software raid (MDADM) I get this message. I damaged the array trying to remove this message. I was forced to recreate the array, and I still get this message. Since the array works, but I still get this message, I am just going to live with the message instead of trying to remove/fix it.

2
  • I know it's been a while but I'm facing a similar issue now :) When you say the message came back after rebuilding the array, can you confirm that (a) the message went away after using gparted and (b) it came back after recreating the array? If so, can you remember how you recreated the array? I'm thinking of failing, removing, gparting and re-adding the drives. Thoughts?
    – jmlnik
    Jun 13, 2019 at 13:26
  • 1
    Figured it out. In my case, I built the raid with whole-devices (instead of using partitions - that's a debate for another day). All I had to do was "zap" the GPT and MBR tables using gdisk /dev/sdX with options x and z
    – jmlnik
    Jun 14, 2019 at 5:30
1
fdisk /dev/your_device

Then type "w" and Enter.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .