Installing Mac OS X Lion in VMware

por | 4 julio, 2011

Shhh! Don’t tell anyone.


Yay! The developer version of OS X Lion is out in the wild!!! Not going to say where I got it from, but I have it and I want to play with it!

But… Being ill-gotten and a pre-beta release, I really don’t want to install it on a hard drive and boot my iMac off of it. Who knows what crazy things could happen? Would suck if something was wrong with the file system (or a virus installed) and it wiped all attached drives!!! So, since I already use VMware Fusion for my OpenBSD web server, why not run Lion in a virtual machine!?

Issue 1. Only server versions of Mac OS X can be run in a virtual machine. Well there’s an easy way around that. Seems the system only checks for the existence of a single file, which can be created to appease the VM Gods.

Issue 2. Lion’s installation and boot process is a lot different and the VM doesn’t know what to make of it – booting from a disk image makes the VM cower into a corner and cry for help. Or just get outright hostile and tell you, «Not here, Jack!» But, as it turns out, there’s a way around that as well. Not as easy as the first obstacle, but possible nonetheless.

Step 1: Create a blank disk image.

Using Disk Utility, create and mount a new image with the following settings,

  • Name: MyInstaller
  • Size: 5 GB
  • Format: Mac OS X Extended
  • Encryption: none
  • Partitions: Single partition – Apple Partition Map
  • Image Format: DVD/CD master

You can name it whatever you want, but be sure to modify the steps below accordingly.

Step 2: Mount the Lion installer image.

The image I obtained mounts as ‘Mac OS X Install ESD’. If yours mounts as something different, then you will need to make any necessary changes to reflect that in the following steps.

Step 3: Mount the Base System image.

The Lion installer image contains a bunch of hidden files, to get to them you’ll need to run the Terminal application. One of these hidden files is BaseSystem.dmg which is used to boot the system.

$ cd «/Volumes/Mac OS X Install ESD»
$ open BaseSystem.dmg

The volume will mount as ‘Mac OS X Base System’

Step 4: Copy the base system.

The entire contents of the base system needs to be copied to your installer image. The ‘Restore’ feature in Disk Utility works great for this. Once that is finished, you can eject the BaseSystem image, it is no longer needed.

Please note, if you chose to «Erase destination», your installer image will now have the same name as the source, ‘Mac OS X Base System’. I rename mine back to ‘MyInstaller’.

Step 5: Setup the ‘kernelcache’ file.

First the file needs to be copied from the Lion installer image to your installer image, then the boot configuration file updated to specify the location of the file.

$ cp «/Volumes/Mac OS X Install ESD/kernelcache» /Volumes/MyInstaller/kernelcache

$ cd /Volumes/MyInstaller/Library/Preferences/SystemConfiguration/
$ sudo vi

Make sure the boot file contains at least the following key/value to specify the location of the kernelcache file,

<key>Kernel Cache</key>

Step 6: Copy the installation Packages.

Before the packages can be copied from the Lion installer image, there’s a file on your installer image that needs to be deleted.

$ sudo rm /Volumes/MyInstaller/System/Installation/Packages

$ sudo cp -R «/Volumes/Mac OS X Install ESD/Packages» /Volumes/MyInstaller/System/Installation/Packages

The copy (cp) command will take a few minutes; it’s copying a few gigabytes of data, so be patient.

Step 7: Flag the system as a server installation.

Again, in order to boot an OS X volume in VMware, it needs to be a server. The system checks for the existence of a file in a specific location; you can imitate a server installation simply by creating that file.

$ cd /Volumes/MyInstaller/System/Library/CoreServices
$ sudo touch ServerVersion.plist
That’s it for the installation disk. Both installer images can be ejected.

Step 8: Create a virtual machine.

This shouldn’t be anything new to you, but I’ll go through each step anyway.

  1. Open VMware Fusion and select «New…» from the File menu.
  2. Click the «Continue without disc» button.
  3. Select «Create a custom virtual machine» and then Continue.
  4. Select ‘Operating System: Apple Mac OS X’ and ‘Version: Mac OS X Server 10.6 64-bit’, then click Continue.
  5. Click the «Customize Settings» button, then name and save the new virtual machine.
  6. Choose «CDs & DVDs» from Settings, then click «Use disc image» and select your installer image.
  7. Choose «Hard disks» from Settings, deselect «Split into 2 GB files» for the pre-created hard drive and click «Apply». *

Feel free to make any other changes to the settings with one caveat, you must use a SCSI hard disk; IDE drives are not recognized by the installer after it boots. Also, if the hard disk is going to be used as a boot disk, it cannot be split into separate 2 GB files, so make sure to deselect that option when the HD is created.

Step 9: Replace the VMs NVRAM.

The default NVRAM will boot up previous OS X systems, but it will not boot up a Lion volume. I have a VM that I initially used as a Snow Leopard system. Booting into that system seems to have set the NVRAM so that it will know how to boot a Lion volume. Here is the NVRAM file from that VM. You can download it and use it in your VM.

  1. Download and uncompress the nvram file.
  2. Locate your VM within the Finder, right click and select «Show Package Contents».
  3. Delete the current nvram file if one exists.
  4. Copy the downloaded nvram file into the folder and rename it to match the name of your VM; mine is named, «Mac OS X 10.7», so the nvram file would be renamed to «Mac OS X 10.7.nvram»

Now you should be able to run the VM and it will boot up to being the installation process.

Step 10: Installing Lion.

After the installation disk boots up, the first thing you should do is run Disk Utility and format the hard drive. All the norms apply; GUID partition map, Mac OS X Extended (Journaled) format, etc. When done, Quit to return to the installer.

Continue with the installation.

When the installation is complete, it will attempt to reboot the VM using the freshly installed OS on the hard disk. It won’t boot, because it’s not a server installation.

Step 11: Forcing the VM to boot from the CD.

VMware will not let you change the startup disk in the VMs settings, so you’ll have to force a change while the VM is running.

Start the VM. As soon as you see the vmware splash screen, hit the escape key. This will bring you to a boot menu, select «Boot Manager»

This will then bring you to another menu where you choose which device to boot from. With «Mac OS X» selected, you can look at the ‘Device Path’ info on the right side of the screen to see the path to the default OS X boot device (this should be the hard disk). You can then move through the list to determine which device would be the CD to boot from. (The Pci or Scsi numbers will be different.) If you choose the wrong device the first time, you can just restart the VM and choose another until you get it right.

Step 12: Flag the new system as a server installation.

After the VM boots from the install disk again, run the Terminal from the Utilities menu.

I labeled my HD, «OS X Lion HD» when I initialized it, so I would enter the following to ‘touch’ the system,

# touch «/Volumes/OS X Lion HD/System/Library/CoreServices/ServerVersion.plist»

Now you can quit the Terminal, choose Startup Disk from the Utilities menu and restart from the hard disk.

Screen Shots

The following screen shots are from a few of the steps above… for visual edification.

Step 4, Disk Utility Restore of ‘Mac OS X Base System’

Step 5, file

Final Thoughts

After running through these steps a few times and trying to force failures, for some reason even the things that wouldn’t work originally are now working!? I haven’t been able to figure out why this is happening? For instance, I can now create hard drive images that are «Split into 2GB files» and I no longer need to repartition the hard drive before installing the OS?


Instructions for installing Leopard client in VMware were from,