Public bug reported:

Binary package hint: parted

Release: Natty daily 2011.04.10. Bug also occurs in Maverick and Lucid.
Package: parted 2.3-5ubuntu4

Parted in Ubuntu is patched to sync the hybrid-MBR with the GPT
partition table on Apple systems. Under certain circumstances, a broken
hybrid-MBR will be produced with multiple overlapping partitions of
partition-ID 0xEE.

The effect can be reproduced, and the cause diagnosed, see TEST CASE and
DIAGNOSIS below.


INCIDENCE AND EFFECTS:

A typical case where this bug may manifest is a dual- or triple-booting
Mac. First the user installs Mac OS X, partition table looks like this:

1. EFI System Partition
2. Mac OS X (HFS+)

Next Ubuntu is installed alongside, partition table is now:

1. EFI System Partition
2. Mac OS X (HFS+)
3. Grub BIOS Boot Partition
4. Linux root (ext4)
5. Linux swap

The resulting hybrid MBR is:

1. EFI protective partition (0xEE)
2. Mac OS X (0xAF)
3. Grub BIOS Boot Partition (0xEE, overlaps partitions 1 & 2)
4. Linux root (0x83)

There are instances in the forums of such situations, eg:
http://ubuntuforums.org/showthread.php?t=1556993
http://ubuntuforums.org/showthread.php?t=1684602

The author of gdisk has also seen this bug: 
http://www.rodsbooks.com/gdisk/hybrid.html
'I'm seeing a lot of problem reports from Mac users who attempt to dual-boot 
with Linux because one of the utilities involved creates a buggy hybrid MBR 
with an extra type-0xEE partition that overlaps others.' 

I will attach the output of 'parted print' and 'fdisk -l' for a triple-
boot system where I encountered this bug.


Both Ubuntu and Mac OS X will continue to boot in my experience, as will 
Windows if present. However, disk utilities may become very confused, and may 
cause damage attempting to fix the broken partition table. Also, Mac OS X will 
believe it is not on a GPT-formatted disk, and will not be able to install 
firmware upgrades.


TEST CASE:

1. Add a new disk to an Ubuntu system or VM. I'll assume this is
/dev/sda .

2. Create a GPT partition table with an EFI system partition:
        a. Run 'parted /dev/sda' as root
        b. In parted, create the table and partition:
        
                (parted) mktable gpt
                (parted) mkpart EFI fat32 1MiB 201MiB
                (parted) set 1 boot on
                (parted) quit
        
        c. Initialize the EFI system partition so parted will recognize it:
                # mkfs.vfat -F 32 /dev/sda1

3. Now we'll add some partitions, and see the bug.
        a. Run parted as root such that it will emulate running on an Apple
                system: 'PARTED_GPT_APPLE=1 parted /dev/sda'
        b. In parted, create a BIOS Boot Partition for grub2. We'll also create
                some extra partitions to make the problem easier to notice.
                
                (parted) mkpart HFS hfs+ 201MiB 500MiB
                (parted) mkpart grub ext2 500MiB 502MiB
                (parted) set 3 bios_grub on
                (parted) mkpart linux-root ext4 502MiB 700MiB
                (parted) quit

4. Examine the MBR with 'fdisk -l /dev/sda'. The results:

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1          26      205823+  ee  GPT
/dev/sda2   *          26          64      306176    0  Empty
/dev/sda3               1          64      514047+  ee  GPT
/dev/sda4              64          90      202752   83  Linux

Notice that the BIOS Boot Partition (sda3) overlaps the first two
partitions. The expected result would be something like:

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1          26      205823+  ee  GPT
/dev/sda2   *          26          64      306176    0  Empty
/dev/sda3              64          64        2048   da  Non-FS data
/dev/sda4              64          90      202752   83  Linux

Or perhaps even:

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1          26      205823+  ee  GPT
/dev/sda2   *          26          64      306176    0  Empty
/dev/sda3              64          90      202752   83  Linux

(Device name /dev/sda3 should be sda4, bug in fdisk?)


DIAGNOSIS:

The proximate cause of this bug is line 317 in gptsync.patch, which sets
the StartingLBA = 1 for any partition of type 0xEE. This should be
changed to only apply to the FIRST partition.

http://bazaar.launchpad.net/~ubuntu-
branches/ubuntu/natty/parted/natty/view/head:/debian/patches/gptsync.patch

** Affects: parted (Ubuntu)
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/757201

Title:
  Overlapping partitions created on Apple GPT

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to