Sunday, May 6, 2012

Snow Leopard 10.6.8 on VirtualBox 4 with Sandy Bridge

Edit: 2013-May-23 -- This doesn't seem to work with new versions of VirtualBox. VirtualBox 4.1.24 seems to be the last version where this will work.

I recently built a new computer and have been trying to get Mac OS X working on it. I don't like Macs well enough to use all the time, but I need one to build software for Mac. Although my machine is capable of being a hackintosh, it is usually easier to build software in a virtual machine which doesn't require restarting.

My old machine was a Core 2 Quad (Kentsfield), and I was easily able to install Snow Leopard in VirtualBox 4 using EFI emulation. However, my new machine is a Core i5 (Sandy Bridge) and the 10.6.3 install disc wouldn't boot in VirtualBox. I eventually ran across some sites saying that Core i users were having trouble using the EFI method and would need to use the standard hackintosh methods to run OS X on non Apple hardware.

I used the iBoot + Easybeast method developed by tonymac, but there were a lot of things that irritated me. Restarting the virtual machine causes a kernel panic. Selecting 'About this mac' from Finder caused Finder to crash, and with it, all currently running applications. There was no sound output at all (not that important to me, but an annoyance just  the same). I thought I might be able to fix these problems by using VirtualBox's EFI emulation.

Then I remembered that Snow Leopard didn't initially run on Sandy Bridge machines. All the ones that shipped had modified versions of 10.6.7 installed. So I decided to combine installation strategies. I would configure VirtualBox to not use EFI and install using iBoot, upgrade to 10.6.8 (which supports Sandy Bridge), and then switch on EFI. This worked perfectly. Below are the steps for getting Snow Leopard 10.6.8 running in VirtualBox 4 using EFI emulation on your Sandy Bridge machine.

Requirements:
  1. iBoot 3 from tonymac (free, but forum registration required)
  2. 10.6.3 Snow Leopard install disc (other 10.6 install discs should work, but I haven't tested this).
  3. VirtualBox 4 (I'm using 4.1.4 on gentoo Linux amd64)
  4. Sandy Bridge core i machine (other machines may work, but I haven't tested this)
  5. Intel VT-x virtualization available and enabled in BIOS
  6. Patience (took me about an hour)
Installation Outline:
  1. Create virtual machine in VirtualBox.
  2. Boot machine using iBoot CD image
  3. Install Snow Leopard
  4. Use iBoot to boot into new Snow Leopard
  5. Update to 10.6.8 using Combo Updater
  6. Reconfigure VirtualBox for EFI
  7. Boot your new Snow Leopard EFI Virtual Machine
Step 1 - Creating the Virtual Machine

Start VirtualBox 4 and create a new machine. Name it whatever you like, but make sure operating system is Mac OS X and version is Mac OS X Server or Mac OS X Server (64 bit). The 64 bit version doesn't actually do anything useful from what I can tell. You don't need it to run Snow Leopard in 64 bit mode. I kept all the defaults for the basic configuration options (1 GiB memory, 20 GiB hard drive). It shouldn't affect anything if you change these, but I haven't tested that.

Edit the settings and go to the System settings. Make the CD/DVD-ROM first in the boot order list. You also need to uncheck Enable EFI. Then go to the Display settings. Set Video Memory to 64 MB and check Enable 3D Acceleration. On the Storage settings, you can select the iBoot ISO for the CD image. Everything else should be good like it is.

Step 2 - Booting using iBoot

Now that your machine is configured, it's time to start it. iBoot comes up very quickly. Once it does, you need to change the CD image to your Snow Leopard DVD. You can use the CD icon at the bottom of the VirtualBox screen to do this while the machine is running. Once you have swapped discs, press F5 so iBoot can detect the new disc. It should now display Mac OS X Install on the boot selection. Go ahead and press Enter to boot this.

Step 3 - Install Snow Leopard

Now the Snow Leopard install will begin. Occasionally, I have found that it might kernel panic sometime during this install. Usually it happens during the boot process, but sometimes it happens later on. If it kernel panics before it tells you it's going to reboot the machine itself, then you have to go back to step 2.

I'm not going to go into the details of installing Snow Leopard. It's pretty straightforward and there are plenty of other guides out there. The basic process is to partition the drive, format it as Mac OS X Extended (Journaled), then tell it to use that disk to install to. I would recommend hitting customize and removing all the optional components before hitting install, but it shouldn't make any difference if you don't.

At the end of the install, when it tries to restart, it will kernel panic. This is a problem we will fix later by turning on EFI, but it won't matter here. It's already done and was going to restart anyways.

Step 4 - Boot into Snow Leopard using iBoot

After the install kernel panics on restart, it's time to swap discs back to iBoot and reset the machine. VirtualBox will probably tell you that the drive tray is locked, but you can ignore that because the machine is locked up anyways.

After you reboot the iBoot CD, you will now have two options: iBoot and whatever you called your Snow Leopard partition (I named mine Snow Leopard). Select the Snow Leopard one and boot it up.

Step 5 - Update to 10.6.8

After you have gone through the first boot process and created your user, you will need to download the 10.6.8 combo update. Then you need to run it and perform the update. When it tries to restart the machine, it will kernel panic again. This time, you can just turn the power off on the virtual machine.

Step 6 - Reconfigure VirtualBox for EFI

Go back to the VirtualBox settings for your Snow Leopard machine. In the system settings, check the Enable EFI box and save the settings. Now close VirtualBox.

Open a terminal window (e.g. konsole, gnome-terminal, Terminal, cmd.exe) and enter the following commands.

VBoxManage modifyvm "XYZ" --firmware efi64
VBoxManage setextradata "XYZ" VBoxInternal2/SmcDeviceKey  "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"
VBoxManage setextradata "XYZ" VBoxInternal2/EfiGopMode 4

Replace XYZ with the name of your virtual machine. I called mine "Snow Leopard". The first one enables the 64-bit EFI firmware, in case you want to boot the 64-bit Snow Leopard kernel. You can still boot the 32-bit kernel using this firmware though.

The second line is hidden within the EFI of real macs as a form of DRM. If you don't have that data in the EFI, Snow Leopard won't boot with EFI.

The third line sets your graphics mode. There are 5 documented VirtualBox graphics modes for EFI. 0 = 640x480, 1 = 800x600, 2 = 1024x768, 3 = 1280x1024, and 4 = 1440x900. Since my monitor is running at 1900x1080, I'm using mode 4. You can leave this line out and it seems to default to 1024x768, which would be fine for most people.

Step 7 - Boot Snow Leopard using EFI

Now you can restart VirtualBox and boot Snow Leopard. You should remove the iBoot CD before you do this. You should now have a working Snow Leopard install in VirtualBox.

Final Notes

It should go without saying, but please buy the copy of Snow Leopard you install. It's only $30.

Updates should work perfectly since you're using a completely vanilla install, but I haven't tested this yet.

Sound is a little iffy. It works, but is not perfect. Sometimes sounds are silenced, sometimes crackly. You want perfect, use a real machine.

By default, Snow Leopard boots using the 32-bit kernel. I don't know if there are any benefits to booting the 64-bit kernel, but if you want to, you need to edit the /Library/Preferences/SystemConfiguration/com.apple.Boot.plist file. There is a Kernel Flags key. In the string value below it, you need to add arch=x86_64 and reboot. Now you will be using the 64-bit Snow Leopard kernel.

12 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Is it possible to enable the EFI without the 10.6.8 update?!

    ReplyDelete
  3. Yes, but Sandy Bridge won't work without it. If you have a Core 2 Duo or Core 2 Quad, you should be able to have any 10.6 version.

    ReplyDelete
  4. I have a brand new PC built useing latest Copr i-7. I run Windows 7 64bit. When I try to boot from the OS X dvd it just shows the apple logo and stops. If I set it up to use EFI and boot from the DVD it gives me a EFI 2.0 shell???
    Any help would be appreciated

    ReplyDelete
    Replies
    1. You sure you have a Sandy Bridge machine and not an Ivy Bridge machine? I don't think Ivy Bridge will work.

      Delete
  5. This comment has been removed by the author.

    ReplyDelete
  6. Thank you!

    I have just got a Snow Leopard 10.6.8 guest running on a Lion 10.7.3 host.

    I had to downgrade from VirtualBox 4.2.1 to 4.1.14 in order to get this to work (VirtualBox 4.2 does not allow "Mac OS X Server" to be selected as an OS; I got as far as the 10.6.8 update but switching to EFI rendered my virtual machine unbootable).

    Once I downgraded and followed your guide to the letter, I managed to get everything working as expected.

    Cheers

    ReplyDelete
    Replies
    1. I just tried it on 4.2.0. It didn't work for me either on EFI. That's unfortunate.

      Delete
  7. I've just installed it and it works like a charm!! Perfect. I have to say that my PC is AMD Based (AMD PHENOM II X6) I just booted with darwin legacy and followed your steps.

    Great job and very nice tutorial!!

    Thank you so much

    ReplyDelete
  8. Lol... It came up with a guru meditation error.. I dont think this is working

    ReplyDelete
  9. Very well written article. It was awesome article to read. I am really impressed by the way you detailed everything. It’s very informative and you are obviously very knowledgeable in this field. Thanks for sharing such an amazing post. Xfinity Tv Package Deals In Florida.

    ReplyDelete