2

This question has been asked before, but the offered solutions didn't work for me.

mao@CatLap:~$ sudo gdisk /dev/sda
[sudo] password for mao: 
GPT fdisk (gdisk) version 1.0.0

Caution: invalid backup GPT header, but valid main header; regenerating
backup header from main header.

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

****************************************************************************
Caution: Found protective or hybrid MBR and corrupt GPT. Using GPT, but disk
verification and recovery are STRONGLY recommended.
****************************************************************************

Command (? for help): 

Using -v and then -q, then rebooting does not fix the problem.

Computer boots up just fine into the OS, though I had to install Wily in UEFI instead of Legacy, as Legacy wouldn't boot up into the OS.

3
  • You have to do a w to write the fixes.Did you install Windows in BIOS mode over a UEFI boot mode. Windows often corrupts the gpt partitions.
    – oldfred
    Nov 11, 2015 at 23:54
  • I did use -w, but it didn't fix it. And the operating system that was in computer before was Elementary OS Freya, not Windows. Ubuntu is in UEFI boot mode, because I couldn't install it in Legacy for some reason.
    – Mao Mao
    Nov 12, 2015 at 0:56
  • Is MBR then really not just a protective MBR but converted to a hybrid MBR/gpt. rodsbooks.com/gdisk/hybrid.html
    – oldfred
    Nov 12, 2015 at 14:24

1 Answer 1

3

Up-front: I'm the author of GPT fdisk (gdisk, sgdisk, and cgdisk), so I understand GPT data structures pretty well.

If Windows is booting in BIOS mode, then it should be booting from an MBR disk. If you've got just one disk, then it looks like Windows is booting in EFI mode, since your one disk uses GPT. (A caveat, though: If your partition table is badly damaged -- say with a hybrid MBR that gdisk is not recognizing for some reason -- it could be it's really a BIOS-mode installation.) I mention this because you said you performed an EFI-mode installation "because [you] couldn't install it in Legacy" mode. Rule #1 of multi-booting these days is to install both OSes in the same mode. In other words, if your Windows installation is in EFI mode, installing Ubuntu in BIOS/CSM/legacy mode is something you should NOT be doing. This may be a bit of a side-track, since it sounds like you did the right thing, but I want to be clear on it because there are a lot of bad procedures out there that suggest installing in BIOS/CSM/legacy mode when that should not be done. I most especially want to make sure that you don't attempt a BIOS/CSM/legacy-mode install to fix your current problem. Absent information that you've really got a BIOS-mode Windows installation, re-installing Ubuntu in BIOS mode would do nothing but create new problems atop the ones you've got now.

Now, to your main problem: I've heard of this sort of thing happening -- that is, gdisk reports a damaged backup partition table, the user fixes it, and it turns up damaged again. The usual cause is that something else is overwriting the backup partition table. Sometimes this is RAID software. Motherboard-based software RAID (often called "fake RAID") can do this because some such systems use space at the end of the disk (where the backup GPT data goes) to store its data. If you've got just one disk, you don't need RAID, so you should disable your RAID settings in your firmware and in all your OSes. Rebooting with and without booting into Windows may help you figure out what's doing the damage, and therefore what you need to adjust. OTOH, if you've got multiple disks and they are being used in a RAID setup, then you need to activate RAID support in Ubuntu. This is covered many places; here seems as good a starting point as any, although I've not read it thoroughly.

Such problems can also occur because of advanced-feature tools like disk encryption or disk compression software. Such tools sometimes dump stuff at the end of the disk, assuming that it's unused. (Under MBR, space after the final partition often goes to waste, so this approach often works. It's not safe, but it often works.) If you've got such tools installed, remove them, or at least research them to figure out if they're compatible with GPT and update or replace them if they aren't GPT-friendly.

If these suggestions don't help, try extracting the last few sectors of the disk to a file with dd. You'll first need to figure out the disk's size in sectors (gdisk will tell you this), then use dd, as in:

sudo dd if=/dev/sda of=foo.img bs=512 skip=100021518

This command copies the contents of the disk, starting at 100021518, to the file foo.img. You'll want to set your skip= value to at least 34 less than the number of sectors on your disk, since GPT normally uses the last 33 sectors. You can then examine the resulting file with hexdump or something similar, as in:

hexdump -C foo.img | less

The idea here is to look for strings or other clues that might tell you what's causing the problems. Of course, you should look at the end of the disk before repairing it. The final 33 sectors should be enough, since that's all that gdisk uses.

3
  • My problem is that I don't have a Windows partition in this laptop at all; it's been Linux since I bought the SSD (it's a Dell Latitude E6410 with a Crucial SSD) I booted into PartedMagic and did a secure erase of SSD, erased the GPT and MBR, the formated the drive. After that, I re-installed Ubuntu 15.10 in Legacy mode (as I used to install all my OS before elementary Freya screwed something up). OS wouldn't boot, took me to a shell. Had to reinstall Ubuntu 15.10 in UEFI for it to be bootable. I apologize if I've made a greater mess of things; partition is not something I'm good at.
    – Mao Mao
    Nov 13, 2015 at 0:41
  • Sorry, I saw oldfred's comment about Windows and my own internal "Windows is installed flag" went on. Still, it's worth checking your firmware settings for anything related to RAID. Also, try running a SMART test on the disk; there's a chance that it's going bad, which might explain the problem.
    – Rod Smith
    Nov 13, 2015 at 20:59
  • Thanks RodSmith, I was having same problem of GPT: damaged. I fix it then it comes again after boot. Switching SATA HD controller settings from RAID to AHCI fixed it. It doesn't happen any more. @MaoMao, I have same model as yours Dell Latitude E6410 Bios A16 & I've only Ubuntu in it. However, I'm still struggling to get it boot in UEFI mode.
    – user.dz
    Jul 5, 2016 at 16:10

You must log in to answer this question.

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