The PC hardware is used in Windows 7 and Ubuntu Linux dual-boot. And users will choose the OS based on the coursework at hand. The iMac hardware is used mostly in OS X. However, there are times when the Windows 7 and Ubuntu Linux functionality is needed on the iMac hardware.
In creating the master iMac install image on a new late-2013 model iMac, several problems were encountered. There are posts on blogs and forums, and all over the 'net that describe how to create a triple boot Mac machine. Some are better than others, but none was completely what I was looking for. Here are some of the best I drew from to create our solution.
Sorry, but I got carried away. This is a long post. I just didn't want to lose the information between now and next year when I'll need to do this again.
The Issues
- Apple uses EFI 1.10.
- This implies that the partitioning scheme is GPT.
- Windows 7 can install to GPT, but only in UEFI mode (EFI 2.x). Note the mismatch with Apple EFI version. So, on Apple hardware, Windows must install in MBR/BIOS/CSM mode.
- The disk must be GPT partitioned, with a "hybrid MBR" partition table to fool Windows 7 installer and installed OS to use the correct portion of the disk.
- Apple hardware requires drivers that aren't present in the default installer for Windows 7. In particular, late-2013 model iMac has USB3, and those drivers are not present. This makes the installation and setup process unable to use the keyboard or mouse.
- Apple provides Boot Camp Assistant to help in the setup for installing Windows and providing the Apple specific drivers. BCA has several limitations, that caused this system not to work out of the box.
- The lack of USB3 drivers prevent the Windows installer from finding the USB3 drivers from a USBstick or USB DVD drive, during the installation. Catch 22.
- BCA also only allows partitioning a disk that has a single HFS+ partition into 2 partitions, one for OSX and one for Windows. Apple's Disk Util won't resize them later and add partitions, without breaking things.
The Solutions
- We have to deal with EFI 1.10 limitations
- GPT partitioning is great. We will have to deal with more flexible hybrid MBR tables though.
- BCA helps build a USB stick that can boot from the Apple Boot Manager. After Windows is installed, it will boot find from the Apple Boot Manager, or using rEFInd, or other boot manager.
- GPT fdisk, will allow us to create the more flexible hybrid MBR table that is consistent with the GPT table, so all OSes use the disk consistently.
- BCA will provide the Apple specific Windows drivers. The Dism tool in Windows will add them to the setup and installation sources on the USB stick.
- BCA will only be used in limited capacity, to work around its limitations. But its useful features will be used.
- The Windows tool, Dism, will be used to add Apple specific drivers to the setup and installation sources. No more chicken and egg problem.
- GPT fdisk and Apple Disk Util will be used to create the desired set and sizes of partitions.
The Process
Here is the process that I used. If you don't like to use the command line, I'm sorry. This process will require you to use the terminal in OS X, the cmd prompt in Windows, and the shell in the Linux installer. If there was a GUI that did all of this, we wouldn't need to document these issues.
This is the outline of the process. Those parts of the process that require more details are documented below this section.
Note that I inserted the USB sticks in the back of the iMac, not into the keyboard USB extension. It makes a difference, particularly when booting the Windows and Linux installers.
CAUTION. I used a system that didn't have any valuable data on it. This process will destroy the data on the disk, and on the 3 USB sticks. This is not for "upgrading" an existing system. CAUTION.
- Create a USB stick installer for OS X.
- Boot the installer. Use Disk Util to create the number, order and size of partitions desired for the final system. Our setup has a Windows partition, a "Sharing" partition, a OS X partition, a Linux partition, and a Linux swap partition. In that order. Set all partitions to be ExFAT type, except for the OS X partition, it should be Mac OS X Extended (Journaled).
- Install a fresh copy of OS X on the system, using the installer app on the USB stick. Reboot into the installed OS, and complete all software updates.
- Install GPT fdisk on OS X system. Use GPT fdisk to create the hybrid MBR that protects the non-windows accessible disk space, and exposes the Windows and Sharing partitions. The Windows partitions should have the boot flag set. Reboot OS X.
- Put a USB stick in the system. Use the Disk Util to erase its contents and replace with an empty FAT file system.
- Obtain an iso of Windows 7. (I used Windows 7 Enterprise, SP1), copy the iso to the OS X system.
- Launch BCA. Ignore the message that says BCA can't work because there are too many partitions. Check first 2 options to install Windows 7 installer on the USB stick, and download the drivers and other software to the USB stick. Safely eject the USB stick.
- On an existing Windows system, use Dism to add the USB3 and graphics drivers to all of the .wim images on the USB stick (sources/boot.wim and sources/install.wim). Also, add the other Apple hardware drivers to the installation .wim image (sources/install.wim). Safely remove the USB stick from Windows, and insert back in iMac.
- Reboot iMac, holding the option/alt key at boot time to interact with the Apple Boot Manager. Select the windows option that represents the USB stick installer.
- During the Windows installation, when selecting an installation destination, be sure to choose the correct MBR partition number. Format it so that NTFS will be correctly used for installation.
- Every time the Windows installer reboots, use the option/alt key to enter the boot manager. This time select the option that represents the internal drive partition of Windows. This should be named whatever you chose in the Disk Util. Leave the Windows installer USB stick in throughout the installation process.
- At the end of the Windows installation process, Boot Camp installer launches and installs Apple software updaters, etc.
- Now, remove the USB stick with the Windows installer, and you have a dual boot system. Use the option/alt key at boot time to activate the boot manager and select the operating system of choice.
- Create a bootable USB stick with the Ubuntu installer. I used the mkusb script, and the Ubuntu mini.iso available at your favorite Ubuntu mirror in (/ubuntu/dists/trusty/main/installer-amd64/current/images/netboot/mini.iso). I image you could use another iso file. Use the command line: sudo ./mksub mini.iso on a linux system. Be sure you know which device is your USB stick, or you might wipe out your system.
- Insert the Ubuntu installer USB stick into the iMac, reboot, and use the boot manager to select the installer. The Apple boot manager will say "WINDOWS" as the title for the USB stick. Don't worry, it's not Windows. Select it, and do your installation.
- When choosing the disk partition(s) to use, be careful, the GPT partition table is presented. Don't delete or create partitions. Just use and format the ones you reserved. Note that this will still re-write the partition table, because the partition types will change for the ones used.
- Don't use the GRUB installation option from the menu. Instead, drop to shell, and manually install GRUB for EFI. See details below.
- Fix the hybrid MBR. In chroot'd shell, apt-get install gdisk; Follow same partitioning options as before to recreate the hybrid MBR. (Maybe using gdisk on OS X to set the types of the Linux and swap partitions in the first place would have avoided this need.)
- Select "Continue without boot loader," and "Finish the installation." Ubuntu still isn't available from the Apple boot manager, but don't worry.
- Test that both OS X and Windows still boot fine.
- Boot into OS X, install and configure rEFInd, so that all 3 OSes are available at boot time.
Details
Making USB Stick OS X Installer
- Boot an OS X system. Download and install the OS X installer from the App Store.
- Insert a USB stick that will be erased and used to create the installer. 8 GByte minimum.
- Format the USB stick using Disk Util as "Mac OS Extended (Journeled)
- Create the installer from the command line. This command line assumes the location of the OS X installer app, and the name of the USB stick volume. Please verify those 2 values before running this from the terminal.
- sudo /Applications/Install\ OS\ X\ Mavericks.app/Contents/Resources/createinstallmedia --volume /Volumes/OSXInstaller --applicationpath /Applications/Install\ OS\ X\ Mavericks.app --nointeraction
- Safely eject the USB stick.
Using GPT fdisk to Create Hybrid MBR Table
- Be sure you know you disk device name. It should be /dev/disk0, but check using the df command.
- Start GPT fdisk: sudo gdisk /dev/disk0
- Examine current GPT: p
- You should see more partitions than expected. The EFI System Partition is hidden from you in Disk Util. Also, a new "Recovery HD" partition was added when installing OS X. Examine the positions, names, and types of the partitions to be sure they make sense. Note the numbers of the Windows and Sharing partitions. If you don't have a Sharing partition, that's fine. However, these partitions should be adjacent on the disk.
- Enter the "recovery and transformation" command mode: r
- Examine the current hybrid MBR, just for reference: o
- Create a new hybrid MBR: h
- Enter the GPT partition numbers to add (Windows and Sharing): 2 3
- Do put an 0xEE partition to protect the front of the disk: y
- For each partition, accept the type of 0x07 (NTFS): 07
- For the Windows partition, make bootable: y
- For the other partitions, don't make bootable: n
- Now, protect the rest of the disk with another partition: y
- I used type 0x80 (minix), because 0xEE did confuse OS X: 80
- Use the "o" and "p" options to make sure things make sense.
- Finally, save the changes to disk: w
- Reboot system immediately following.
Installing Apple Drivers on Windows Installer
- There are two links above for how to use the Dism tool. The one to use depends on the OS you are using to patch the Windows 7 installer. One is for Windows 7, the other is for Windows 8. I used Windows 7, so my examples will show that.
- Boot your existing Windows system. Insert the Windows 7 Installer USB stick created by BCA.
- From the USB stick, copy sources/boot.wim and sources/install.wim from the USB stick to the disk. For example, I put them on my Desktop. My USB stick was mounted as drive K.
- Open an privileged cmd prompt (Run as administrator).
- List the images in the .wim file with: Dism /Get-ImageInfo /ImageFile:C:\Users\myuser\Desktop\boot.wim
- Note the name of the images.
- My boot.wim file had 2 images, and install.wim had 1 image. I installed the USB3 and Graphics drivers from BootCamp into all images. I installed ALL of the BootCamp drivers in the install.wim image.
- Make a directory to mount the images on: mkdir C:\offline
- One at a time, I processed each of the images with these steps:
- Mount a particular image in a .wim file: Dism /Mount-Image /ImageFile:C:\Users\myuser\Desktop\boot.wim /Name:"Microsoft Windows Setup (x64)" /MountDir:C:\offline
- Be sure you put the name in quotes, and get it right. That's the selection mechanism within the .wim file.
- Add all of the USB3 and graphics drivers: Dism /Image:C:\offline /Add-Driver /Driver:"K:\$WinPEDrivers$" /Recurse
- If its an install image, add ALL drivers: Dism /Image:C:\offline /Add-Driver /Driver:"K:\BootCamp\Drivers" /Recurse
- Unmount the image, saving changes: Dism /Unmount-Image /MountDir:C:\offline /Commit
- Copy both boot.wim and install.wim back to the sources directory on the USB stick.
- Safely eject the USB stick.
GRUB EFI Installation
The grub-pc package is for BIOS/MBR. We don't want it, instead we need the grub-efi package. The Ubuntu installer doesn't have an option from the menu for this yet. So, we'll do this during the installation, instead of "Install the GRUB boot loader on a hard disk."
- Use alt-F2 or "Execute a shell", to obtain a shell prompt
- chroot /target
- apt-get update; apt-get install grub-efi-amd64
- mkdir /EFI; mount /dev/sdb1 /EFI
- grub-install --target x86_64-efi --efi-directory /EFI
- update-grub
- umount /EFI
- Exit the shell