I've been trying to get the dual boot to work for a few days now. I installed rEFIT and then installed Ubuntu, when installing I selected the option to put the grub loader on the ubuntu partition. After installing, I don't see the Ubuntu install in the rEFIT loader, and I cannot repair the partition table. I boot OS X and get the output from the partition inspector, which is below.
*** Report for internal hard disk ***
Current GPT partition table:
# Start LBA End LBA Type
1 409640 781659639 Mac OS X HFS+
2 781660160 970772479 EFI System (FAT)
3 970772480 976772479 Linux Swap
Current MBR partition table:
# A Start LBA End LBA Type
1 1 409639 ee EFI Protective
2 409640 781659639 af Mac OS X HFS+
3 * 781660160 970772479 83 Linux
4 970772480 976772479 82 Linux swap / Solaris
MBR contents:
Boot Code: None
Partition at LBA 409640:
Boot Code: None
File System: HFS Extended (HFS+)
Listed in GPT as partition 1, type Mac OS X HFS+
Listed in MBR as partition 2, type af Mac OS X HFS+
Partition at LBA 781660160:
Boot Code: None
File System: ext4
Listed in GPT as partition 2, type EFI System (FAT)
Listed in MBR as partition 3, type 83 Linux, active
Partition at LBA 970772480:
Boot Code: None
File System: Unknown
Listed in GPT as partition 3, type Linux Swap
Listed in MBR as partition 4, type 82 Linux swap / Solaris
Does anyone know how I can go about fixing this?
Best Answer
First, there appears to be an error in your GPT layout: The partition beginning at sector 781660160 is identified on the GPT side as an EFI System Partition (ESP); but on the MBR side, it appears as a Linux partition with an ext4 filesystem. Given the way this identification has been done, I trust the MBR data on this one. Chances are you or the installer mistakenly set the "boot flag" on the partition. Using libparted-based programs, setting the "boot flag" on a GPT partition actually sets the ESP type code, which should never be set on a Linux partition. (The ESP is required to hold a FAT filesystem and should hold EFI boot loaders and related files, not a Linux installation.) This error isn't likely to be causing your problem, but it's conceivable it's a contributing factor. Thus, I recommend booting a Linux emergency system and using GParted,
parted
,gdisk
, or some other tool to adjust the type code appropriately. Using GParted orparted
, remove the "boot flag" from the Linux partition; or usinggdisk
, change the type code from EF00 to 8300. Note that these tools will probably show another ESP, this one with a FAT filesystem. You should leave it configured as an ESP (with its "boot flag" or EF00 type code, depending on the tool you use).Second, I recommend you switch from a BIOS-mode boot of Linux to an EFI-mode boot. This will obviate the need to use a hybrid MBR, which you're using now. Hybrid MBRs are ugly and dangerous hacks. You can install a suitable EFI-mode boot loader without too much difficulty. The easiest to set up is likely to be my rEFInd, which is a fork of the (now-discontinued) rEFIt; however, the procedure I'm about to describe works only with 3.3.0 and later kernels. Ubuntu 12.10 and later, including Ubuntu 12.04.2 (but not the original 12.04) come with suitable kernels. The procedure is:
.zip
file from its downloads page.install.sh
script.ext4_x64.efi
file from the rEFInd package to the/EFI/refind/drivers_x64/
directory (which you'll have to create). (This assumes you install to the default location; if you install rEFInd to your ESP or install manually elsewhere, you'll need to adjust the path appropriately.)vmlinuz
.ro root=/dev/sda2
to the boot options and press Enter. Linux should launch.mkrlconf.sh
script that came with rEFInd. This will create a configuration file that should obviate the need to addro root=/dev/sda2
to your Linux options the next time you boot; instead, Linux should launch directly when you select its option and hit the Enter key.At this point, your system will be basically functional. You can remove the hybrid MBR by using the
gdisk
program (specifically, by typingx
followed byn
followed byw
) or by making any minor change to your partitions withparted
or GParted. You may also want to tweak the rEFInd configuration by editing the/EFI/refind/refind.conf
file under OS X; see the rEFInd documentation for details.