Triple Boot via BootCamp

From OnMac.net Wiki
Jump to: navigation, search

Back.png Back to BootCamp


This procedure allows you to triple boot Mac OS X, Windows XP and Linux. It has been successfully used to setup a MacBook, but is untested on the iMac/mini. Therefore if you try this you do so at your own risk.

Contents

Before you start

This procedure takes 3-4 hours (with broadband downloading), which is mostly Windows & Linux installation. Also note that if you want to undo this process without destroying and reformatting your JHFS+ partition, you'll need iPartition. This is not reversible (nondestructively) with Apple's tools.

Before you begin you will need the following:

Software


Please note that this procedure can potentally Destroy all data on you machine's hard disk drive, so make a backup first.

If you don't know how to make a clean back up of your system, you can visit the How To Backup your Mac page.

For detailed Ubuntu installation instructions, check out Triple_Boot_via_BootCamp_Ubuntu

Background

If you want to just get on with installing, skip this section and go on to install. Otherwise keep reading.

Issues in brief

Setting up a machine for triple-booting is largely just partitioning the hard drive and installing each OS. The issues that cause problems are:

In turn:

Note that 64-bit Windows Vista comes with EFI support.

So in summary:

Disk Partitions and their Limitations

The primary problem with installing operating systems on a Mac is the partitioning system. Intel Macs use the new GPT method to partition drives. (GPT is part of the new Extensible Firmware Interface (EFI) standard proposed by Intel as a replacement for the outdated PC BIOS). This is supported by Mac OS X (obviously) and Linux. However Windows can only be installed on a machine with a legacy (MBR) based partitioning system. In order to overcome this, Boot Camp uses both systems, and herein lies the difficulty in triple booting. Currently there is no partitioning software available apart from diskutil (included with Mac OS X 10.4.6) that can create dual GPT/MBR partition system drives. Current GPT based partitioners (e.g. GNU parted) wipe the MBR portion, whereas current MBR partitioners (e.g. fdisk, Partion Magic) can't edit GPT.

There are certain things you can do with fdisk that won't hurt GPT when booted using BIOS Emulation/Compatibility mode, because of the layout of the MBR and GPT relative to each other and the way the BIOS Emulation protects certain parts of the GPT/MBR tables:

However, any changes to the actual MBR partition table structure are impossible without ruining your GPT structure.


In other words we have to manually partition the drive using diskutil in order to get the necessary partition structure for triple booting. However it gets worse. MBR only supports 4 primary partitions and GPT does not support extended partitions. Combining these two limitations means that a dual partition system disk can have a maximum of 4 primary partitions. In addition, Apple reserves the first primary partition for the "EFI System Partition". That leaves us with only three partitions to play with, one for each OS. Hence, we cannot have a Linux swap partition, instead we must create a swapfile. Also, for some reason Boot Camp expects the Windows "C:" drive to be the last partition present on the drive. If it isn't, Windows setup will crash with a "cannot find hall.dll" error after the first reboot.

In addition, it may be best to stick with Apple's advice and format the Windows partition as FAT32. Due to limitations in Windows XP's disk manager, the FAT32 partition will normally be limited to a maximum of 32GB. However that said, some of these limitations can be overcome using the advanced partitioning methods listed in the next section.

Also, Intel based macs shipping with 10.4.7 or later pre-installed appear to be capable of partitioning a drive using MBR in a traditional manner and booting Mac OS X from it. This may dramatically reduce the complexity of triple booting setup (at least for newer hardware) but information in this area is currently very scarce, and is not referred to again. (Note that writing to boot sectors is usually separate from writing to the master boot record, and can be done at any time)

Trick to make a swap partition nevertheless : (added by Muchel Roche on 13/11/06) Start partitioning as depicted above, install Windows, and then launch Linux install. Now we have as partitions :

At the point of using the partitioning tool during the install, gparted (at least, but I guess most of the EFI aware partitioning programs that may be used by the different distros) is capable to shrink your windows (FAT32) partition in order to create a 5th partition in the end, which you can easily make 1 or 2 Gb wide, to hold your swap partition. It's not a problem in Linux to have five EFI partitions since it's "EFI aware", so it can use the swap. It doesn't bother Windows XP once installed because the bootloader (I use rEFIt) still knows where it is. All I had to do was to update the BIOS-alike partition scheme which rEFIt produces as partition scheme for Windows to run. And it seems not to be a problem for Windows which has no access to it and doesn't know it ! The only drawback of this technique is that in he eventuality that you'd have to reinstall windows (but no one can see why ;-) it may cause a problem because the Windows partition isn't the last in that case which may cause a problem between Boot Camp insisting for windows to be the last and windows only knowing four partitions. I haven't tested yet this configuration and cannot figure what exactly could go on. Anyway, the fix wouldn't be that annoying : simply boot under a Linux live CD, fire up gparted and kill the swap to free space so that your drive goes back to the four partitions scheme. Re-install windows, reboot on live-CD and recreate the swap partition. Hopefully linux should boot again with no trouble.

Another simple fix is to use lvm to separate the big linux partition into as many partitions as you need. This will be backward compatible with MBR and EFI/GPT. See debian etch install below

Advanced Methods for Partitions/Filesystems

If you want to use FAT32, but you need your partition to be larger than 32GB, you can use a utility called fat32format via a non-dos bootdisk or bootcd (think BartPE) to perform the actual formatting. Windows will recognize and interact with the drive with no problems.

With respect to filesystems, Mac OS X can recognize and mount both NTFS and FAT32. However it will not recognize them properly unless the the GPT partition type is set to "Microsoft Basic Data". The only way you can set the partition to this type is to format the disk via diskutil and specify "MS-DOS FAT32" as the filesystem type. Confusingly, this will allow Mac OS X to correctly recognize either a FAT32-formatted partition or an NTFS-formatted partition. There is no way to format a partition as Linux, etc., and then convert it to "Microsoft Basic Data" (short, perhaps, of manually editing the drive itself with a hex editor). GNU parted does not support this partition type, "ntfs" and "fat32" in parted will not be recognized by the Mac. Furthermore, parted clobbers the MBR record. This cannot be properly restored by rEFIt, even with the filesystem sync utility. Basically you have to get it exactly right the first time.

Once you have one or more partitions in "Microsoft Basic Data" type set up, you can then proceed with the install below. However if you are trying to create a setup like below you will have some trouble:

The problem with this is that Windows installer will recognize the 2nd partition as "Active" and make it your C drive. This is bad because OS X expects the Windows boot partition to be the last on the disk. You can switch the active partition via a regular MBR fdisk utility such as Free FDisk, which is included on various boot CDs such as the very useful EBCD. GPT doesn't know anything about the active partition, and doesn't need to. Once this is switched then Windows will swap the drive letters and the 4th partition will be "C".

Finally, there is as small hint about NTFS write support in terminal under "man mount_ntfs". It says that it is very experimental and does not support a number of important NTFS features. For information read in this forum. Mac OS X itself has unfortunately not been proven to have a working write support for NTFS yet. Though, you can use NTFS-3G for Mac OS X for that.

Booting your Mac

This article lists two alternative methods for booting the operating systems installed on your Mac. The recommended method is to use the graphical boot menu supplied by the rEFIt project. The advantage of this method is that it presents you with a single, customizable interface. However the disadvantages are that you need to bless it onto your hardware, and it needs to be reinstalled every time you upgrade Mac OS X.

As some people may be uncomfortable with blessing their equipment, an alternative method exists were you can chainload the LILO bootloader from the Windows XP (NTLDR) bootloader. The problem with this method is that LILO must be reinstalled every time you change your Linux kernel, and it requires you to use multiple boot menus in order to select your OS.

With respect to booting Linux, unfortunately it is not possible to use GRUB out-of-the-box with Boot Camp. GRUB tries to access legacy hardware that is not present in the Intel Macs. See here [1] for a patch to GRUB to make it work in the Intel Macs.

Note: This section previously stated: "GRUB tries to install the stage 1.5 code into the section of the disk reserved for the primary GPT record. Apple's firmware prevents this from occurring." This is wrong. GRUB checks the MBR partition table itself, detects that there is no room to embed a stage1.5 and falls back to coding the sector location of stage2 into stage1.

Installing the Operating Systems

OSX

Boot Camp & partitioning

Alternatively, you can burn the disk to a CD (or DVD) without running the Boot Camp Assistant. (This is also necessary if you wish to update the drivers after setting up triple-booting.) To do so, Right/Control Click on the Boot Camp Assistant and select 'Show Package Contents'. Then copy the Contents/Resources/diskimage.dmg file to the Desktop and use Disk Utility to burn that image to a CD.

  /dev/disk0
   #:                   type name               size      identifier
   0:  GUID_partition_scheme                    *233.8 GB disk0
   1:                    EFI                    200.0 MB  disk0s1
   2:              Apple_HFS Macintosh HD       233.4 GB  disk0s2 
  sudo diskutil resizeVolume [disk identifier] [disk size] [partition type] ["Partition label"] [partition size] [partition type] ["Partition label"] [partition size]

so, you'll enter something like...

  sudo diskutil resizeVolume disk0s2 60G "Linux" "Linux" 17G "MS-DOS FAT32" "Windows" 15G
  sudo diskutil resizeVolume disk0s2 60000M "Linux" <name of linux volume> 17000M "MS-DOS FAT32" <name of windows volume> 15000M

1. Resize the current partion size first;

  sudo diskutil resizeVolume disk0s2 60G

Reboot it.

2. Creat the rest of partions;

  sudo diskutil resizeVolume disk0s2 60G "Linux" "Linux" 17G "MS-DOS FAT32" "Windows" 15G



Windows XP

"The software you are installing has not passed Windows Logo testing...", but otherwise don't need to do anything.

I think as of Boot Camp 1.1.2, the following is taken care of by the drivers CD. If not you will likely want to add some of the following utilities to make Windows more usable with your Mac hardware, notably:


You now have a dual boot system! But obviously, we aren't finished yet.

Linux

 
# Global LILO settings
boot=/dev/sda3                            
timeout=5              
default=Linux 	

# Kernel specific LILO settings
image=/boot/<kernel image file>	
label= Linux		
read-only               	
root=/dev/sda3          	
  
 
/sbin/lilo
  

Via Debian etch

Further advice is at: Brian W. Carver's HOW-TO, but it is now out-of-date: notably, the network card is supported and X is set up correctly.

Lots of Debian-specific information is at: Debian Wiki on MacBook

Alternatively, you can set up a lvm logical volume from the linux partition, and then define as many partitions as you need in the lvm system. Lilo is able to boot a system that has all the partitions under lvm !
chroot /target apt-get install refit
/target/sbin/gptsync /dev/sda

(This is from Debian Wiki on MacBook.) Presuming that this works, in the next step, LILO will succeed, and you won't need to do it manually.

nano /target/etc/lilo.conf

Comment out the reference to Windows XP at the end (rEFIt is dealing with booting, not LILO), then setup LILO via:

chroot /target
/sbin/lilo -v -P ignore

-v makes it verbose, and, crucially, -P ignore tells LILO to ignore the confusing, out-of-sync hybrid GPT/MBR (it may be possible to instead use gptsync, but that involves a reboot). This should succeed; now exit the shell, and choose "Continue without a boot loader", as the Debian installer doesn't know that you manually setup LILO.

dd if=/dev/zero of=/swap bs=1024 count=1048576
mkswap /swap
swapon /swap
chmod 600 /swap

Now you are actually done with installing; there is some hardware configuration (below).

Hardware: What works, what doesn't?

See Debian Wiki on MacBook for up-to-date info on hardware especially.

apt-get install 915resolution

...and it works automatically (restart X, or perhaps reboot). Without this, you get 1024x768 resolution, which is very fuzzy. (This loads the 1280x800 video mode onto your Intel 915 video card, so that it works properly.) Note that your xorg.conf will list 1280x800 (presuming you selecting this during install), but without 915resolution, it won't work.

(I imagine this should only be necessary on the Mac Mini, MacBook, and the low-end iMac; Mac Pros, MacBook Pros, and the higher-end iMacs don't use Intel graphics.)

Currently, your network card and X are setup correctly, and monitor does with 915resolution; sound works as of Linux kernel 2.6.18-rc1.

I do not know about other accessories (iSight camera), and I don't know an easy way to setup the keyboard.

Boot

Booting your mac via rEFIt

cd /efi/refit
./enable.sh

Now restart your mac. If everything has been done correctly, the rEFIt menu will be displayed with icons for all three operating systems. Select the OS of your choice using the arrow keys and return.

gptsync: if the GPT & MBR get out of sync (as they may when installing Linux), use gptsync to fix this: at the rEFIt screen, choose the command prompt, let it boot, then type gptsync at the prompt, and it will check if GPT & MBR are in sync, and offer to fix them if they are not.

Booting your mac via NTLDR

You do not need to do this if you have installed rEFIt; this uses the Mac native loader (to select between Mac & Windows), plus the Windows NT NTLDR (to select between Windows & Linux), instead of rEFIt (which selects between all 3, via a nice GUI).

 
mkdir /mnt/windows && mount -t vfat /dev/sda4 /mnt/windows
cd /mnt/windows
dd if=/dev/sda3 of=linux.mbr bs=512 count=1
echo 'C:\linux.mbr="XYZ Linux"' >> /mnt/windows/boot.ini
cd && umount /mnt/windows
  

Now restart your Mac. If everything has been done correctly, when you hold down the OPTION/ALT key, you will be given an option to boot to OSX and Windows. Select Windows. NTLDR will now show up and present you with the option to either boot into Windows or Linux. Select Linux!

Further issues

Linux Drivers

Upgrading Boot Camp from 1.0 to 1.1

On the 16th August 2006, Apple released an updated version of Boot Camp which includes drivers for iSight, amongst other things.

(The point of this upgrade is just to install newer drivers, so you just need to create a new drivers disk; you don't need to do any repartitioning or reinstalling of OSes.)

However the Boot Camp Assistant will not run on triple boot setups due to the different disk layout. In order to upgrade, you need to use the following workaround:

Restoring your Mac to its original state

The following instructions worked for me on Mac OS X 10.4.8 with BootCamp 1.1.2.

Basically, there are two operations that need to be done:

  1. Remove the Linux and Windows partitions.
  2. Resize the Mac partition to the full size of the disk.

Removing the partitions can be done with "gpt":

  1. Read the "remove" and "show" sections of "man gpt".
  2. Reboot using the Mac OS X install disk.
  3. Run the disk utility and make sure all volumes on your harddisk are unmounted. I've had to repeat this step after each gpt command, which, for some reason, caused them to get mounted again.
  4. Run the terminal.
  5. Use "diskutil list" to find the device identifier of your harddisk (usually, it's "/dev/disk0").
  6. Use "gpt show" to find the indices of the volumes you want to remove (if you've completed the triple booting sequence successfully, it should be 3 and 4).
  7. Use "gpt remove -i <index> <device identifier>" to remove the Linux and Windows volumes. Replace "<device identifier>" and "<index"> with the values you found in the previous steps. Obviously you will need to run this command once (with the corresponding index) for each volume you want to remove. Note: Volumes are mounted automatically whe you remove a partition. Dismount them again.
  8. Close the terminal, run the disk utility, check that the only remaining volume is the one you wanted. Make sure it's mounted.
  9. Close disk utility and quit the installer. In the "Startup disk" dialog, select Mac OS X on your harddisk.
  10. After rebooting, you should be back in your regular Mac OS X, with the Linux and Windows volumes gone.

Resizing the Mac volume is surprisingly difficult. Although "diskutil resizeVolume" claims to be able to grow volumes as well as shrink them, in reality, it fails with a "Resizing encountered error No space left on device (28) on disk" error message. Luckily, Boot Camp Assistant has an option to restore your disk to its original single-volume state, and that option will make that volume span the entire disk. To convince it to do this, however, you first need to use it to split your Mac volume into a smaller volume and a Boot Camp (Windows) volume. The steps:

  1. Run Boot Camp Assistant. Note, this will only work after you've removed the Linux and Windows volumes, as Boot Camp Assistant expects a single-volume disk.
  2. Skip the "Burn a Macintosh Drivers CD" step and split your disk into two volumes as instructed by Boot Camp Assistant. The actual sizes of the volumes don't matter.
  3. Tell Boot Camp Assistant you do not want to install Windows now. It will then make you reboot.
  4. Run Boot Camp Assistant and choose the "Restore to a single Mac OS partition" option. It should show you that the new size of your Mac volume will be as large as the entire harddisk. Confirm the restore, and you're done.

Resizing Windows and Linux Partitions

 umount /dev/disk0s2
 umount /dev/disk0s3
 umount /dev/disk0s4
 gpt remove -i 3 /dev/disk0
 umount /dev/disk0s2
 umount /dev/disk0s4
 gpt remove -i 4 /dev/disk0
 
 diskutil resizeVolume disk0s2 40G "Linux" "Linux" 51G "MS-DOS FAT32" "Windows" 20.5G
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox