Introduction

This posting documents how I configured triple boot environment of Ubuntu 9.10 karmic, Mac OS X 10.6 and Windows 7 on ?one of my machines. All operating systems are installed on a single physical disk. Grub 2[1] boot loader installed by Ubuntu will be used as the primary boot loader. Grub will be then used to boot Chameleon[2] boot loader which boots Mac OS X. Grub boots Ubuntu’s Linux kernel directly and Windows by chain-loading the Windows boot loader from the Windows partition.

Partitioning the disk

Partitioning the disk causes headache and requires some tweaking as we have to install both GUID Partition Table[3] and Master Boot Record Partition Table[4] on the same disk. Mac OS X only supports system disks with GPT. But Windows doesn’t support booting from a disk with GPT[5]. Ubuntu is happy to boot from disks paritioned using both GPT and MBR. Thus we have to create hybrid GPT/MBR boot record[6].

We’re going to do the initial partitioning of the system disk from within Mac OS X installer environment using diskutil(8)[7] tool. Follow the instructions in the posting Create Mac OS X 10.6 Snow Leopard USB installation media for Hackintosh and create bootable Mac OS X installer USB media that works with your system. Of course if your system boots with the retail Mac OS X DVD, you can use that too.

Next we have to decide the partition table layout. When installing Grub 2 on a disk with GPT, it’s recommended to have BIOS Boot Partition[8],[9]. With the hybrid partition table in place, you’re limited to only 4 partitions that are available to Windows. And two of these partitions are reserved (EFI Partition and BIOS Boot Partition) so you only have 2 primary partitions to configure at your will. Also it’ll be difficult to work with the partitioning after we’ve finished with the installations and gotten everything to work so it’s better to do good initial planning.

Ubuntu 9.10 karmic and later install Grub 2 that is capable of handling LVM. Since we’re going to install Ubuntu on logical volume(s), there’s not need for a separate partition for /boot file system. That’s great!

I partitioned my 600GB disk as follows:

  • Partition 1: 200MB HFS+ volume labeled EFI. This is created automatically when partitioning the disk with diskutil(8)[7]. Chameleon boot loader code and support files are also installed on this volume. This way there’s no need to do any customization to the Mac OS X volume described below.
  • Partition 2: 2MB volume for the BIOS Boot Partition. Used by Grub.
  • Partition 3: 150GB NTFS volume for Windows.
  • Partition 4: 50GB Physical volume for volume group managed by LVM. The volume group will house the Ubuntu installation.
  • Partition 5: 100GB Mac OS X system volume labeled Hackintosh HD for the operating system, applications and user home directories.
  • Partition 6: ~300GB HFS+ volume labeled Video for video archive and scratch space used during editing of home videos.

To partition the disk boot Mac OS X installer and launch Terminal.app from the Utilities menu. First identify the system disk.

    -bash-3.2# diskutil list

In my system the system disk is /dev/disk7. Then I partitioned the disk using the following command.

    -bash-3.2# diskutil partitionDisk /dev/disk7 GPT \
        "MS-DOS FAT32" %noformat% 2M \
        "MS-DOS FAT32" %noformat% 150G \
        "MS-DOS FAT32" %noformat% 50G \
        "Journaled HFS+" "Hackintosh HD" 100G \
        "Journaled HFS+" Video 0b

As noted above, this will create total of six partitions. In addition to the five partitions listed above, the 200MB EFI partition is automatically created by diskutil(8)[7] as the first partition of the disk. I marked the Windows, Linux and BIOS boot partitions temporarily as FAT32 so that the space gets allocated for these partitions. The Windows partition will be formatted as NTFS when installing Windows 7, the Linux partition will be added to the volume group when installing Ubuntu and Grub installer will use the BIOS boot partition.

Installing Chameleon boot loader

The empty, just partitioned hard disk is not bootable and won’t be even after installing Mac OS X in the next step. But we can copy Chameleon boot loader and its configuration from the Mac OS X USB installer to the system disk. See my guide for more details about Chameleon. These steps assume that the Mac OS X installer was created like documented in that posting. While still in the Mac OS X installer with Terminal.app running, execute the following commands.

  1. Create HFS+ file system on the EFI volume and mount it.

    -bash-3.2# newfs_hfs -v EFI /dev/disk7s1
    -bash-3.2# mkdir /Volumes/EFI
    -bash-3.2# mount_hfs /dev/disk7s1 /Volumes/EFI
    
    
  2. Mark the EFI file system so that fseventsd doesn’t keep any logs there.

    -bash-3.2# mkdir /Volumes/EFI/.fseventsd
    -bash-3.2# touch /Volumes/EFI/.fseventsd/no_log
    -bash-3.2# chmod -R g-rwx,o-rwx /Volumes/EFI/.fseventsd
    -bash-3.2# chown -R root:admin /Volumes/EFI/.fseventsd
    
    
  3. Copy the Chameleon boot loader binaries to the root of the EFI volume. You really need the boot file, which is the last stage of Chameleon boot system and contains bulk of the Chameleon code, but it’s a good idea to have the images of the first stages at hand, too.

    -bash-3.2# ditto /Volumes/Hackintosh\ Snow\ Leopard\ Install\ Disk/boot /Volumes/EFI
    -bash-3.2# ditto /Volumes/Hackintosh\ Snow\ Leopard\ Install\ Disk/boot0 /Volumes/EFI
    -bash-3.2# ditto /Volumes/Hackintosh\ Snow\ Leopard\ Install\ Disk/boot1h /Volumes/EFI
    
    
  4. Copy Chameleon support file directory Extra to the EFI volume.

    -bash-3.2# ditto /Volumes/Hackintosh\ Snow\ Leopard\ Install\ Disk/Extra /Volumes/EFI/Extra
    
    
  5. Unmount the EFI volume.

    -bash-3.2# umount /dev/disk7s1
    -bash-3.2# rmdir /Volumes/EFI
    
    
  6. Eject the system disk so that you can write to the block device file in the next step.

    -bash-3.2# diskutil eject /dev/disk7
    
    
  7. Now you can copy the Chameleon initial boot code from the installer file system to the Master Boot Record at the beginning of the system disk.

    -bash-3.2# dd if=/Volumes/Hackintosh\ Snow\ Leopard\ Install\ Disk/boot0 of=/dev/disk7 bs=440 count=1
    
    
  8. Then copy the Chameleon 2nd stage boot code from the installer file system to the beginning of the EFI partition.

    -bash-3.2# dd if=/Volumes/Hackintosh\ Snow\ Leopard\ Install\ Disk/boot1h of=/dev/disk7s1
    
    
  9. Bootloader installation is now ready. Mount the Mac OS X volume so you can install Mac OS X onto it.

    -bash-3.2# diskutil mount /dev/disk7s5
    
    
  10. Finally, quit Terminal.app.

Installing Mac OS X 10.6 Snow Leopard

Go ahead and install Mac OS X normally on the Mac OS X volume (Hackintosh HD). After the installation is finished, the machine should boot to Mac OS X as we installed the Chameleon boot loader to the Master Boot Record and support files to the EFI partition in the previous steps. It’s a good idea to create backups of the Master Boot Record of the system disk at this stage so you can revert back if needed. You can use e.g. dd(1)[10] in Mac OS X installer shell.

    -bash-3.2# dd if=/dev/disk7 of=/Volumes/BackupVolume/mbr-backup bs=512 count=1

Installing Windows 7

When the system disk was partitioned above with diskutil(8)[7], it also created the hybrid GUID/MBR partition table. You can now boot Windows 7 installer and format the partition dedicated to Windows as NTFS. Proceed to install Windows on this partition. After Windows is installed, the machine now boots Windows as the Windows installer replaced Chameleon boot code in the Master Boot Record with its own boot code. No need to worry, we’ll get Mac OS X back after installing Ubuntu and configuring Grub.

Installing Ubuntu 9.10 karmic

Use Ubuntu alternate installer[11]. Boot the installer and proceed to the disk partitioning step. Choose manual partitioning and create a volume group to the partition dedicated to Ubuntu, create required volumes and install Ubuntu there. When the installer prompts for boot loader device installation, don’t answer yet but switch to the console (Alt-F2). We need to activate the BIOS Boot Partition first. In the following setup /dev/sda is the physical system disk.

  1. Mount the special file systems at the target file system.

    ~ # mount -o bind /dev /target/dev
    ~ # mount -o bind /sys /target/sys
    ~ # mount -o bind /proc /target/proc
    
    
  2. Enable BIOS Boot Partition using parted(1)[12].

    ~ # chroot /target parted /dev/sda set 2 bios_grub on
    
    
  3. Unmount the special file systems at the target file system.

    ~ # umount /target/dev
    ~ # umount /target/sys
    ~ # umount /target/proc
    
    

Now switch back to the installer virtual console (Alt-F1) and input the system disk block device name /dev/sda and finish with Ubuntu installation.

Restoring hybrid partition table

After installing Ubuntu, you should be able to boot it using Grub. However, Ubuntu installer and parted(1) have destroyed the hybrid GPT/MBR partition table. But we can fix that using the gptsync(1) tool which is part of the rEFIt[13]. gptsync package is available for Ubuntu[14], but unfortunately the version in karmic is too old to support BIOS Boot Partitions[15]. This has been fixed in the version 0.13-4 of the package. Until there’s a working version of gptsync package in Ubuntu, you can use the package from Debian[16]. When you have a version of gptsync(1) installed which supports BIOS Boot Partitions, go ahead and re-create the hybrid partition table.

    ~$ sudo gptsync /dev/sda

Updating Grub boot menu

Ubuntu installer should detect the Windows 7 installation and create a Grub menu entry for it. It’ll also detect the Mac OS X installation and create menu entry for that, too. However, that is no good to us since it uses Grub’s native Mach kernel loading facilities[17] but we want to use Chameleon to boot Mac OS X.

So let’s create a custom menu entry that will boot Chameleon. Save the following script as /etc/grub.d/99_local_chameleon and set it executable.

#!/bin/sh

cat <<END_OF_MENU_ENTRY
menuentry "Mac OS X via Chameleon" {
        insmod hfsplus
        set root=(hd0,1)
        multiboot /boot
}
END_OF_MENU_ENTRY

Download script

    ~$ sudo chmod 755 /etc/grub.d/99_local_chameleon

And update the Grub configuration.

    ~$ sudo update-grub

Now you should have Grub menu from which you can choose whether to boot Ubuntu, Mac OS X or Windows.

Fixing Windows

Unfortunately, partition changes related to Ubuntu installation breaks Windows on my machine. When trying to boot Windows, I get Windows Boot Manager error screen with status 0xc00000e. To fix this, boot to Windows Recovery Environment and start Command Prompt. With Windows 7 retail DVD in hand, boot it, choose your language and locale settings and choose Repair your computer. If the Recovery Environment asks Do you want to apply repairs and restart your computer, choose No. Choose Use recovery tools that can help fix problems starting Windows and then clck Command Prompt. In the Command Prompt find the drive that contains the Windows installation. Most likely it’s C:. Run the following commands to repair Windows Boot Catalog.

    bcdedit /set {default} device partition=c:
    bcdedit /set {default} osdevice partition=c:
    bcdedit /set {bootmgr} device partition=c:

It should now be possible to boot Windows from the Grub boot menu.

References

  1. The gnu.org GRUB manuals explicitly states that windows cannot be loaded directly with GRUB. I’m not sure if the difference here being that your tutorial uses GRUB2 and the manual is for 1.98, or not…

  2. You don’t clearly specify where or when the EFI volume is created. You say it’s automatically created by the MacOSX installer, but then you go to make the partitions from the command line, don’t include the EFI volume, and continue on to use that EFI volume from the command line before even installing the MacOSX…

It’s very confusing…

Comment by MisterVirtual 2010-11-08T01:56:45 EET

Hi,

Regarding your comments…

  1. Fine, Grub (even version 2) can’t load Windows directly, it chain-loads the Windows boot loader. By saying “directly” I meant that Grub can handle booting of Windows without user installing a 3rd party boot loader in a similar manner as Chameleon is needed for booting Mac OS X.
  2. If you read carefully, you can see that I didn’t state the Mac OS X installer would create the EFI partition, but diskutil(8) command line tool. With the installer I was referring to the installer environment where you can use Terminal.app, Disk Utility.app, etc., not actual Mac OS X setup program.

But yeah, these points weren’t exactly clear so I re-worded the posting. See the diff.

Comment by tj 2010-11-08T12:55:51 EET

Hi, you mention a BackupVolume, but never where it is created. Did you create it on a USB disk with Time Machine or something similar? Thanks!

Comment by jbbrs 2010-12-12T06:12:43 EET

Hi, you mention a BackupVolume, but never where it is created. Did you create it on a USB disk with Time Machine or something similar? Thanks!

Comment by jbbrs 2010-12-12T06:23:03 EET

Hi,

BackupVolume just refers to any writable disk/volume you might have on your system for instance when you insert an USB stick or disk or maybe your TimeMachine disk that you wish to use for backing up the MBR. What that disk really is and what it is called is up to you so creating the volume is not covered here.

Comment by tj 2010-12-12T09:52:05 EET
Hi, I tried reading your post as it was the closest site I’ve found to helping me solve my issue (chameleon?). It was a bit too complicated for my level of tech saviness, however and was hoping to have an explanation in simple language how I can boot my Dell Mini 10v from an external drive. The 8GB SSD wasn’t big enough to fit the Mac OS X (10.6 I think though it might be 10.6.2 as well) a friend had prepared for me on a USB key (but I’d partitioned & erased the Ubuntu OS that was there, leaving my netbook now without an OS) so I installed it on a 500GB external drive instead. I was able to restart, set up (after registering and everything) and even install Firefox. Because of that and the updates, I needed to restart the netbook and since I haven’t been able to go beyond the grey page with the logo, no matter how much I play around with the setup, disable the bluetooth, etc. Would you be able to advise me on what I need to do. I’d be most grateful.
Comment by tte 2011-01-04T23:56:01 EET
Hi, I tried reading your post as it was the closest site I’ve found to helping me solve my issue (chameleon?). It was a bit too complicated for my level of tech saviness, however and was hoping to have an explanation in simple language how I can boot my Dell Mini 10v from an external drive. The 8GB SSD wasn’t big enough to fit the Mac OS X (10.6 I think though it might be 10.6.2 as well) a friend had prepared for me on a USB key (but I’d partitioned & erased the Ubuntu OS that was there, leaving my netbook now without an OS) so I installed it on a 500GB external drive instead. I was able to restart, set up (after registering and everything) and even install Firefox. Because of that and the updates, I needed to restart the netbook and since I haven’t been able to go beyond the grey page with the logo, no matter how much I play around with the setup, disable the bluetooth, etc. Would you be able to advise me on what I need to do. I’d be most grateful.
Comment by tte 2011-01-05T00:06:08 EET
Sorry I have never experimented with Mac OS X on PC laptops..
Comment by tj 2011-01-06T05:37:49 EET

Hola mi nombre es Antonio, verás tengo dos discos duros sata, en hd0 tengo windows 7 y ubuntu 11.10, y en hd1 mac osx leon con todas las actualizaciones (10.7.3). Si booteo con el disco de mac hd1 arranca mac y win7 pero no sale el icono de linux en el chamaleon y mac osx leon funciona de maravilla. Si booteo con el hd0 en grub2 me salen los tres sistemas pero mac no carga y se reinicia. Instalé burg, muy bonito y aparecen los tres sistemas pero mac no carga, he encontrado esto:

“Si has creado un sistema de arranque dual con MacOSX Snow Leopard y Ubuntu y encuentras que GRUB2 no arranca tu Mac, puedes seguir las instrucciones a continuación para agregar la entrada de inicio correcta a GRUB2 y tu sistema quede a 100%. sudo gedit /etc/burg.d/40_custom agregamos lo siguiente al final del archivo despues de “# the ‘exec tail’ line above.”: menuentry “MacOS X León” { insmod hfsplus set root=(hd0,X) # !!!!! change X to the Mac partition multiboot /boot } Guardamos la configuración,cerramos y volvemos a un terminal y ponemos lo siguiente : sudo update-burg”

pero no me funciona, quería saber si conoces una solución, por cierto el disco de mac hd1 tiene guid y el de windows-linux grub. gracias y un saludo. Mas datos de mis discos: /dev/sda1—ntfs–––177Gb—boot–-Windows7 /dev/sda2—ext4—/––-10Gb–––-Linux /dev/sda3—ext4—/home—110Gb–––-Linux /dev/sda4—swap–––—2Gb–––-Linux /dev/sdb1—fat32—efi–200Mb—boot–- /dev/sdb2—hfs+–––-95Gb–––-MacOsxLion /dev/sdb3—ntfs–––205Gb–––-Datos

Comment by Antonio 2012-03-03T13:18:47 EET

Bueno pues para el que le pase lo mismo: Abrir terminal y escribir: sudo mkdir /boot/chameleon cd /boot/chameleon sudo wget http://downloads.bodhilinux.com/jeff91/misc/boot0

sudo gedit /etc/grub.d/40_custom

Añadir abajo del todo: menuentry “Chameleon” –class osx –class darwin –class os { insmod part_gpt insmod hfsplus set root=’(hd0,1)’ search –no-floppy –fs-uuid –set=root 70D6-1701 parttool ‘(hd0,1)’ boot+ chainloader ‘(hd0,2)’/boot/chameleon/boot0 } y luego:

sudo update-grub2

Se agregara al archivo grub.cfg.

Pero ahora tengo el problema de que en vez de salir el icono de la manzana, sale uno con un signo de interrogación, porfaa ayuda.

Comment by Antonio 2012-03-03T21:22:06 EET

Bueno pues para el que le pase lo mismo: Abrir terminal y escribir: sudo mkdir /boot/chameleon cd /boot/chameleon sudo wget http://downloads.bodhilinux.com/jeff91/misc/boot0

sudo gedit /etc/grub.d/40_custom

Añadir abajo del todo: menuentry “Chameleon” –class osx –class darwin –class os { insmod part_gpt insmod hfsplus set root=’(hd0,1)’ search –no-floppy –fs-uuid –set=root 70D6-1701 parttool ‘(hd0,1)’ boot+ chainloader ‘(hd0,2)’/boot/chameleon/boot0 } y luego:

sudo update-grub2

Se agregara al archivo grub.cfg.

Pero ahora tengo el problema de que en vez de salir el icono de la manzana, sale uno con un signo de interrogación, porfaa ayuda.

Comment by Antonio 2012-03-03T21:28:07 EET

Hello there. First of all let me say thank you ! I found you guide extremely useful & working. I was drived crazy by other guides and have experienced everytime boot issues.

I am trying now to install Ubuntu 13.10 and when I try to “Mount the special file systems at the target file system.” I get error. I don’t remember exactly what it states, but it is related to missing item.

I see the boot partion (1M size) available for selection about booting partition under Ubuntu. Why do you say we have to activate it prior to chose it during installation ? What do I risk if I directly select it ?

Thanks Paolo

Comment by paolo 2013-12-10T13:15:01 EET

I bypassed the mentioned issue by “sudo” in front of those commands ;)

That said, I’d like to keep up using Chamaleont instead of Grub. Any suggestion about how to do it ? I am scared I can destroy everything I have done up to now. Ciao paolo

Comment by paolo 2013-12-11T09:11:18 EET

I bypassed the mentioned issue by “sudo” in front of those commands ;)

That said, I’d like to keep up using Chamaleont instead of Grub. Any suggestion about how to do it ? I am scared I can destroy everything I have done up to now. Ciao paolo

Comment by paolo 2013-12-11T09:16:46 EET

It is indeed challenging to have it all booting from one hard disk.

Most command line instructions depicted here imply super user, ownership and permissions of several internals of the Linux OS. Many will and are intimidated by the many error messages after typing such and so command as above which is very discouraging. Ubuntu is becoming used by more and more command line illiterates or forgotarites like me.

My machine is a Pentium 4 3GHz hyperthreading. A DC7600 HP motherboard. Installed ‘Vanilla’ OS X via Multibeast procedure on Tonymacx86 on a GPT partitioned (via the Apple installation Disk) harddisk. Version 3.5 to be more precisely. There’s info on the web how to activate the Ethernet port in a non-intimidating manner. Snow Leopard 10.6.7 is the maximum level. Higher up fails. I’m not interested in Lion etc. ‘Vanilla’ meant that the installation actually happened via e retail Apple DVD after use of an EFI replacing boot CD. (ModBin for example).

What I did earlier in the past is installing Windows XP on another empty MBR partitioned harddisk. I even didn’t partition it beforehand I believe. It was done by the installer and it gave me the choice not to partition the whole disk and leave space unallocated for the other systems later on.

I then installed Ubuntu and made sure the grub2 bootloader was NOT installed on the MBR or better said I made sure it was installed on the partition where UBUNTU was installed. Concerning partitioning I chose ‘something else’ so I could create an extended partition to install UBUNTU in. PAY ATTENTION during the installing of you UBUNTU so NOT to install the bootloader on /sdx (x being the letter of the drive) however to install it on /sdxn (n being the partition number where UBUNTU is installed).

Using the UBUNTU live disk (DVD for UBUNTU LTS 14) I used gparted to copy the OS X partition from the GPT harddisk to the MBR harddisk where Windows XP and UBUNTU are already installed on, each on their own partition. Windows XP on an NTFS partition and UBUNTU on an EX4 partition. Then I had 3 partitons on this MBR harddisk. Windows XP on an NTFS PRIMARY PARTITION, UBUNTU on an EXT4 PARTITION inside an EXTENDED PARTITION and OS X on a HFX+ PARTITION.

I’ve been trying for a while now to get all three accessible. OS X was always a problem. Maybe UBUNTU 14 LTS had an improvement because I only had to change mach_kernel inside GRUB2 generated script to legacy_kernel to make it boot from GRUB2 without further issues. Legacy kernel because Pentium 4 demands this (check Tonymacos86 - Multibeast 3.5 on the web). I used Grub Customizer to do that (look for Grub Customizer on the web). Chameleon-Chimera seem to be out of the game now this way now.

It’s important to know which OS is on which partition! The small script in the above guide works also however I had to change hd(0,1) to hd(0,2) for obvious reasons, OS X being on partition hd(0,2). Also this script works provided the Chameleon or Chimera bootloader is installed on the OS X partition! The invoked text mode of this bootloader isn’t really appealing so maybe an automatic start would be nice.

Comment by Benzopal 2015-04-21T23:15:55 EEST