2013-03-02

Mac OS X 10.7.2 on VirtualBox 4.1.14 [with XCode 4.21]

Intro

Since I really like having multiple operating systems on my computer I decided to try out Apple's OS on a virtual computer. Not really an Apple fan, though I wanted to see what all the hype is about. After searching the web I found a few install instructions but none of them were simple or worked straight away. So I decided to write my own tutorial about my trip to Apple land.

Start

Since I will be using this machine for development purposes I will also install XCode on OSX. So let's see what I used to install Mac OS X:
  • VirtualBox 4.1.14
  • iATKOS L2 Mac OS X 10.7.2 for X86
  • 20 GBytes of space
  • 64bit processor
  • (optional) dmg2img
  • (optional) XCode 4.21
My primary machine has i7 2600 with 16GB RAM.

Making VirtualBox machine

Make a new Virtual machine and select Mac OS X as operating system and for version select Mac OS X Server (64bit). Give it at lest 1024MB of Base Memory. But the more the better. I found mine stopped lagging considerably after I jumped from 2048MB to 4096MB.

Startup disk should be at least 20GBytes. First I tried with 10GBytes but when I wanted to install anything OS said there is not enough space. So leave it at default. I recommend you set dynamically allocated size, since the size will grow when the system needs it. And it won't take your disk space (in case you're using small SSD disk).

I selected VDI as file type since I will use it only for VirtualBox. If you have other needs then select the appropriate file type.

Setting VirtualBox machine

I'm posting images because they are easier to understand.

But first you need to make ISO image out of downloaded Mac OS X image file (found at the link below).

This you do with the dmg2iso tool:


dmg2img your_downloaded_file.dmg mac_osx_lion.iso


You can mount DMG image same as ISO but since I didn't do it I can't comment on it.
After you've made the ISO image you can mount it in the Storage section in Virtualbox (as seen below).


  • Basic tab in General



  • Motherboardboard tab in System (don't check the Enable EFI)


  •  Processor tab in System (I recommend you don't use too many processors, your whole computer will get stuck if Mac OS X stops responding)


  •  Acceleration tab in System


  •  Video tab in Display (here you can also turn on Remote Display for your Mac OS X)


  •  Storage (mount CD/DVD drive with Mac OS X ISO/DMG image)


  •  Audio (select Intel HD Audio)


  •  Network (usually I select bridged because I need separate IP address)


  •  Enable USB controller


Mac installation

After setting up everything you can start the machine. It will automatically start from the mounted ISO file. Again I'm posting pictures because it's easier to see the procedure.


  • After running you're going to get this screen. Let it boot and wait for the unitl the welcome screen appears


  •  You're going to notice you can't install, because there is no disk drive available. So with mouse go to the Utilities menu and click Disk utility


  •  Select the disk and go to the Erase tab. Type in the name for your disk and press Erase. Again confirm you want to erase disk (this disk is virtual by the way)


  •  After finishing close the Disk utility and you will be transported back to the install screen. Don't click install just yet. Click the Customize button.


  •  In the customize section select the following choices that are listed below. Some instructions say you can select graphic card. But unfortunately Virtualbox emulates Intel. So it's kind of useless to install Nvidia or ATI drivers. And anyway Mac OSX will complain that no Nvidia/ATI hardware found. So resist the choice to select.

  •  After selecting all the necessary options go back to the install screen and click Install. Finally. After the install finished (depending on your configuration 12-30 min) you will see the screen showed below. You have to manually reset computer by selecting Machine->Reset. Be careful to unload the ISO image before that (otherwise we go to fresh install again). After first restart machine will probably ask again to restart. So do that.

  •  After the second restart we come to the welcome screen. Setup your keyboard, location and optional information (Apple ID, registration). And setup user account.


  •  After setting up everything your Mac OS X system will start. You have made it!


Setting the installed OSX

First thing to do after installing is to disable updates. This you do by clicking the Apple icon in the top left corner and select Software updates and untick the Check for updates option. That's it. Of course you can also update, but be careful not to upgrade to a newer version (in the time of writing 10.7.4) because your system will not boot then (figured it out the hard way). Everything else (iTunes, Java updates,...) is OK to update.

Install XCode (optional) 

Since I'm going to use Mac OS X for development I decided to install XCode. You can download XCode from Apple's development site. You have to register to download but otherwise it's free.

I tried many versions of XCode and the only one that worked was 4.21 version. The rest need a newer system (10.7.4). This became a problem when I tried to use friends iPhone for development. Since he was using 5.1.1 operating system it was too new for the installed XCode so I couldn't do anything. But you can still use this XCode to get to know how to develop in it.

Tips

I found out that Mac OS X shares a little bit different keys than Windows. So in Mac copy/paste work by pressing the Windows key (if you have a Windows keyboard) instead of Ctrl.

Tweaks

  • Disable window animations 

Open up Terminal and type in the following command:

defaults write NSGlobalDomain NSAutomaticWindowAnimationsEnabled -bool NO


  • Disable mail reply animations

Open up Terminal and type in the following command:

defaults write com.apple.Mail DisableReplyAnimations -bool YES

  • Disable the switching Spaces animation 

Open up Terminal and type in the following command:

defaults write com.apple.dock workspaces-swoosh-animation-off -bool YES && killall Dock

  • Showing / hiding sheets

Open up Terminal and type in the following command:

defaults write -g NSWindowResizeTime -float 0.01


  • Window zoom

Open up Terminal and type in the following command:

defaults write com.apple.finder AnimateWindowZoom -bool false


Better performance

    As I said before if you want a better performance try to apply as much memory to the virtual machine as possible. In the end I disabled audio because I didn't need it. And I think it helped with the overall machine stability (it didn't get stuck so much).

    Troubleshooting

    • Guru Meditation -2301 (VERR_REM_VIRTUAL_CPU_ERROR)

    Found out I didn't set Mac OS X (64bit) system in VirtualBox, so always set it to 64bit.
    • F8 doesn't work / No startup screen

    Didn't follow some tutorials advice and forgot to uncheck Enable EFI (Special OSes only)

    • Mac OS X doesn't boot (stuck at Apple screen)
    One of the hiccups of having Mac OS X on virtual machine. Just try to restart/reset the machine until it comes into the OS X (usually not more than 3 times).


    Useful links

    1 comment: