Ubuntu – How to fix MBR partition prior to Ubuntu Installation? A partition overlaps GPT backup sectors


My main problem is that i have just acquired an ASUS laptop with WINDOWS 7 and I want to install Ubuntu on it.

I want to have a dual boot to choose between both Operating systems, I read that it's better to first install Windows and then Ubuntu, because Windows installer overwrites Ubuntu's boot loader.

So, i tried to install Ubuntu 12.04 LST from an USB pendrive, but when it check for other OS doen's find the Windows 7 system.

I checked posibled causes and re-installed Windows 7 from the Recovery partition in the HD but i got the same result.

Aparently Ubuntu installer found two partition tables (GPT and MBR) and it doesn't know which one to use.

I used gdisk to try to solve the problem.

From the fdisk and gdisk outputs below, i know that i have to fix my MBR partition but i don't know how.

ubuntu@ubuntu:~$ sudo fdisk -l

WARNING: GPT (GUID Partition Table) detected on '/dev/sda'! The util fdisk doesn't support GPT. Use GNU Parted.

Disk /dev/sda: 500.1 GB, 500107862016 bytes
256 heads, 63 sectors/track, 60563 cylinders, total 976773168 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: 0x7834646f

  Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1  4294967295  2147483647+  ee  GPT    

ubuntu@ubuntu:~$ sudo gdisk -l /dev/sda
GPT fdisk (gdisk) version 0.8.5

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

Found valid GPT with protective MBR; using GPT.

Warning! Secondary partition table overlaps the last partition by
33 blocks!
You will need to delete this partition or resize it in another utility.
Disk /dev/sda: 976773168 sectors, 465.8 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): B1142EF0-26CB-4F15-9C42-AFC122E50E2A
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 976773134
Partitions will be aligned on 2048-sector boundaries
Total free space is 122884062 sectors (58.6 GiB)

Number  Start (sector)    End (sector)  Size       Code  Name
  1            2048          411647   200.0 MiB   EF00  EFI system partition
  2          411648          673791   128.0 MiB   0C01  Microsoft reserved part
  3          673792       391383039   186.3 GiB   0700  Basic data partition
  4       391383040       802693119   196.1 GiB   0700  Basic data partition
  5       925575168       976773167   24.4 GiB    2700  Basic data partition

Command (? for help): r

Recovery/transformation command (? for help): o

Disk size is 976773168 sectors (465.8 GiB)
MBR disk identifier: 0x7834646F
MBR partitions:

Number  Boot  Start Sector   End Sector   Status      Code
  1                     1   4294967295   primary     0xEE

Best Answer

I'm the author of gdisk, and I agree with what psusi has written, with the caveat that I can't know what's really on /dev/sda5, so I can't say if it's safe to remove it. If it's the stuff that you've burned to your recovery DVDs, it should be safe to delete it, though.

If there's sufficient free space on /dev/sda5 (about 17 KiB), you should be able to resize the partition using GParted or a Windows tool, IF that tool doesn't flake out because of the illegal partition table. You might be better off backing it up to another disk, deleting it, and then restoring it. You'll need to use a backup/restore method that enables restoring to a smaller partition, though. (Alternatively, you could shrink /dev/sda4 by just a bit to make room to create a new /dev/sda5 that's as big as it is now.)

Also, on an unrelated matter, you seem to have a UEFI-based PC. On such systems, the advice to install Linux second isn't as important as it is on BIOS-based systems. (U)EFI still has a lot of flaws, but despite those problems, it's got much saner boot management than does BIOS, and Windows behaves itself better with respect to other OSes on EFI than it does on BIOS.

You might want to use gdisk to change your Linux partitions' type codes from 0700 to 8300 to keep them from showing up as unformatted disks in Windows. See here for more on this issue.

Related Question