Saturday, September 28, 2013

Hackintosh Lion Triple Boot with Windows 7 and Linux

My hard drive recently failed and took out all my operating systems. After replacing the drive, I spent a week figuring out how to get all three systems working again. I didn't have a Lion USB installer, because I reused that USB flash drive at some point. I didn't have a working Snow Leopard install to create one. And even after getting those things, I learned that new hard drives are different than the one I had, and they don't play nice with Chameleon due to a new kind of layout called Advanced Format. It's been a long time since I had to do this, so I had forgotten what order things had to be done in to work correctly. It was absolutely horrible, and not something I want to have to relearn (again).

This is a step-by-step guide for installed Lion 10.7.5, Windows 7, and Linux (I use gentoo, but any Linux distro should work) on a Gigabyte GA-Z68A-D3H-B3 motherboard with F13 BIOS (no UEFI) with an Advanced Format Drive. Some of these steps may be very specific to my situation, so it may take some adaptation for your setup. I wish you luck. Feel free to post comments if you have questions about any of this.

This guide assumes that you have a working computer, an optical drive burner, a USB flash drive (8 GB minimum size), access to the Internet, Windows 7 Install DVD, Snow Leopard Install DVD (or a working Snow Leopard 10.6.8 install), and a Linux installer. I can't really help you get any of these things, so I'm just going to assume you already have them. There are some troubleshooting questions at the bottom that cover things I ran across while hashing out this process.

I have tried this entire process from scratch on a blank drive to ensure it works. Some steps may not be necessary on your setup. You don't need to install Snow Leopard if you already have a Lion USB Installer (myHack or UniBeast should both work). You don't need to "fix" Chameleon for Advanced Format Drives if you don't have an Advanced Format Drive (if your hard drive was made after 2011 and is >= 1 TB, it's probably Advanced Format). I used myHack rather than UniBeast (or whatever). Whatever Lion USB Installer you have should be fine, but I have only used myHack. UniBeast has never worked for me. Some steps describe installing drivers or DSDT. You should only use my choices if you have my motherboard and BIOS version. You'll have to figure out what the correct choices are for your motherboard. This process is very similar for Mountain Lion, but I use Lion because I need Xcode 3 and haven't figured out how to make that work in Mountain Lion yet.

Step 1: Install Snow Leopard 10.6.8
Prerequisites:
  1. Snow Leopard Install DVD (10.6.3 is what I'm using)
  2. Snow Leopard 10.6.8 Combo Update http://support.apple.com/kb/dl1399
Boot iBoot CD
When it start up, swap the iBoot CD for the Snow Leopard Install DVD
Press F5 to rescan the disc, and boot into the Mac OS X Install DVD
Install Snow Leopard
Reboot using iBoot CD
Boot the new Snow Leopard Install
Run UpdateHelper and Reboot
(if you don't reboot, the combo updater will destroy Snow Leopard)
Boot Snow Leopard using iBoot
Run the Combo Updater and Reboot

Step 2: Create the myHack USB Installer
Prerequisites:
  1. Bootable Snow Leopard 10.6.8
  2. Lion App from the Mac App Store (I'm using 10.7.3)
  3. USB 8 GB flash drive
Boot into Snow Leopard 10.6.8 using iBoot
Download myHack (version 3.2 Beta 8) from http://myhack.sojugarden.com/
Run myHack to create the USB Installer on your Pen Drive with the Lion App

Step 3: Partition the drive with gptfdisk
Prerequisites:
  1. System Rescue CD http://www.sysresccd.org
Boot the System Rescue CD
From the prompt, run gdisk
  1. # gdisk
In gdisk, make 6 partitions
  1. EFI partition – Type EF00, 200 MiB
  2. Windows 7 partition, Type 0700, 120 GiB
  3. Lion partition, Type AF00, 120 GiB
  4. Linux boot partition, type 0700, 128 MiB
  5. Linux partition, Type 8300, 120 GiB
  6. Linux Swap partition, Type 8200, 4 GiB
Go into the recovery and transformation options (command 'r') and build the hybrid MBR (command 'h'). Add partition 2 to the hybrid and make it bootable.

Write the partition table to disk and shutdown.

Step 4: Install Lion
Prerequisites:
  1. myHack Lion Installer
Boot using the myHack Lion Installer USB flash drive.
Use Disk Utility to format the 2nd partition as HFS+ Journaled.
Install Lion.

Step 5: Install Windows 7
Prerequisites:
  1. Windows 7 Install DVD
Boot the Windows Install DVD.
Install Windows to partition 2.

Step 6: Install Linux
Prerequisites:
  1. Linux Install DVD
Boot the Linux install DVD.
Choose custom partitioning. Partitiot 4 is /boot, Partition 5 is /, and Partition 6 is swap.
Install grub to the boot partition (/dev/sda4 most likely)
Install Linux.


Step 7: Install Chimera so we can boot between the three OSes
Prerequisites:
  1. Lion, Windows 7, and Linux installed
  2. myHack USB Installer flash drive
  3. MultiBeast 4.7.0 http://www.tonymacx86.com
  4. Combo Updater 10.7.5 if you have an old Lion App
Boot Lion from the myHack USB Installer flash drive in single user mode
run the commands at the prompt to mount the root directory
# /sbin/fsck -fy
# /sbin/mount -uw /
Delete the /Extra directory and reboot
# rm -rf /Extra
# reboot

Boot Lion using the myHack USB Installer flash drive in normal mode
Update Lion to 10.7.5 if it is not already on that version or later
Rename the DSDT-GA-Z68A-D3H-B3-F13.aml to DSDT.aml and place it on your Desktop
Run MultiBeast with the following options
  1. Audio – with DSDT ALC889
  2. Networking – lnx2mac RealTek R1000 driver
Step 8: Fix Chimera install on Advanced Format drives
Prerequisites:
  1. An Advanced Format Drive
  2. System Rescue CD
If you have an Advanced Format Drive, when you boot up, you will get a gpt boot0 error issue, or it might just boot right into Windows and ignore Chimera altogether. To fix this, you need to install part of Chimera on the partition. If you have a hard drive made after 2011, it's probably an advanced format drive. You can skip this step if you don't have such a drive.

Boot the System Rescue CD.
Install Chimera to the partition
  1. # mkdir /mnt/lion
  2. # mount /dev/sda3 /mnt/lion
  3. # cp /mnt/lion/usr/standalone/i386/boot1h /tmp
  4. # umount /mnt/lion
  5. # dd if=/tmp/boot1h of=/dev/sda3 bs=4096
Reboot

Questions:

Q: Do you have to use gptfdisk to partition?

A: Although I haven't tested this much, you should be able to use almost any partitioner to partition your drive (e.g. Disk Utility or gparted). However, there are some caveats.

First, only gptfdisk can make the hybrid MBR which is required for Windows 7. You will have to use it for this at the least.

Disk Utility will only make FAT32 and HFS+ partitions. You could probably make FAT32 partitions and then reformat as needed, but that seems odd to me.

If Windows is not the first partition (after the EFI system partition), then it will display blank space where the “gaps” in the partitions are, which I do not like. Disk Utility also leaves gaps after the partitions it creates; another thing I don't like.

Any change to the partition tables by utilities other than gptfdisk will usually destroy the hybrid MBR, which means you'll have to go back in to recreate it (Linux installers sometimes do this anyway).

With the exception of the hybrid MBR, none of these issues should be much of a problem, but since you have to use gptfdisk for the hybrid MBR, I figure you might as well use it for the whole thing. I haven't run across any problems doing it this way so far.

Q: Why doesn't Windows 7 boot or let me install?

Use gptfdisk to check the hybrid MBR. If something messed it up (and a lot of install things can do this), you'll need to recreate it.

The Windows BCD loader might be messed up. You can try using the Windows Install DVD to repair it.

Q: Can I use a different partition scheme?

A: That should not be a problem. However, I have not tested it much.

I know grub2 likes a special grub-bios partition, but I have only used grub legacy, so I don't know much about it.

You might want to add another linux partition for /home (or /boot, /tmp, etc). This should not be a problem. In fact, it's probably a good idea.

You might want to change the partition sizes. My size choices were pretty arbitrary. I just got a new 1 TB drive to replace the one that failed. I'm not even using all of it right now.


Q: Why doesn't Linux show up in Chimera?

A: There are two potential issues I have seen. First, grub might not have been installed to the /boot partition. Recent linux installers I have tried will not let you install grub to a partition, and grub2 doesn't recommend installing to a partition at all. Since I use grub legacy on gentoo, it's not an issue for me. You should be able to force grub2 to install on a partition by using grub-install /dev/sda4 –force (or maybe grub2-install – it varies from distro to distro). The second issue is the partition type. Although it doesn't make sense to me, Chameleon will not recognize grub if the partition type is not 0700 (Microsoft basic data). Using 8300 (Linux partition) will render it invisible to Chameleon.



2 comments:

  1. This information is meaningful and magnificent which you have shared here. I am impressed by the details that you have shared in this post and It reveals how nicely you understand this subject. I would like to thanks for sharing this article here. Xfinity Tv Package Deals In Florida.

    ReplyDelete