Overlapping partitions created on Apple GPT
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
parted (Ubuntu) |
Fix Released
|
High
|
Colin Watson | ||
Lucid |
Won't Fix
|
High
|
Unassigned | ||
Maverick |
Invalid
|
High
|
Unassigned | ||
Natty |
Fix Released
|
High
|
Colin Watson |
Bug Description
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://
http://
The author of gdisk has also seen this bug: http://
'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.
Related branches
Changed in parted (Ubuntu): | |
status: | New → Confirmed |
importance: | Undecided → High |
Changed in parted (Ubuntu Natty): | |
status: | Confirmed → Triaged |
assignee: | nobody → Colin Watson (cjwatson) |
milestone: | none → ubuntu-11.04 |
tags: | added: patch |
Formatting of fdisk output is pretty borked, is there a way to fix that?
In any case, here are the pre- and post-install partition tables when installing Ubuntu on my triple-boot system:
PRE GPT:
Number Start End Size File system Name Flags
17.4kB 20.5kB 3072B Free Space
1 20.5kB 210MB 210MB fat32 EFI System Partition boot
2 210MB 160GB 160GB hfs+ Macintosh HD
160GB 160GB 135MB Free Space
3 160GB 320GB 160GB ntfs Windows
320GB 320GB 335kB Free Space
PRE MBR
Device Boot Start End #cyls #blocks Id System
/dev/sdb1 0+ 25- 26- 204819+ ee GPT
/dev/sdb2 25+ 19481- 19457- 156282164 af HFS / HFS+
/dev/sdb3 * 19498+ 38913- 19416- 155952128 7 HPFS/NTFS
/dev/sdb4 0 - 0 0 0 Empty
POST GPT
Number Start End Size File system Name Flags
17.4kB 20.5kB 3072B Free Space
1 20.5kB 210MB 210MB fat32 EFI System Partition boot
2 210MB 160GB 160GB hfs+ Macintosh HD
160GB 160GB 135MB Free Space
3 160GB 239GB 78.5GB ntfs Windows
239GB 239GB 848kB Free Space
4 239GB 239GB 1049kB bios_grub
5 239GB 317GB 77.9GB ext4
6 317GB 320GB 3352MB linux-swap(v1)
320GB 320GB 335kB Free Space
POST MBR
Device Boot Start End #cyls #blocks Id System
/dev/sdb1 0+ 25- 26- 204819+ ee GPT
/dev/sdb2 * 25+ 19481- 19457- 156282164 af HFS / HFS+
/dev/sdb3 19498+ 29040- 9543- 76650692 7 HPFS/NTFS
/dev/sdb4 0+ 29040- 29041- 233271295+ ee GPT
Notice that sdb4 overlaps sdb1 in the post-install hybrid-MBR.