Install OS X Lion in VMWare

featured-image

I came across this rather cool guide on how to install the Lion Developer Preview on to a VMWare Fusion image instead of creating an additional boot partition or overwriting your current OS. Great for testing non-destructively!

I’ve reproduced the guide below (with added screenshots), but in no way take credit/responsibility for it. Use it at your own risk.


A downloadable PDF version of this guide can be found here.

Steps 1-6

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 following steps accordingly.

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.

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’

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’.

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 com.apple.Boot.plist

Make sure the boot file contains at least the following key/value to specify the location of the kernelcache file. Mine didn’t, so I edited mine using TextWrangler.

<key>Kernel Cache</key>
<string>\kernelcache</string>

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.

Steps 7-12

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.

Create a virtual machine.

    • Open VMware Fusion and select “New…” from the File menu.
    • Click the “Continue without disc” button.
    • Select “Create a custom virtual machine” and then Continue.

    • Select ‘Operating System: Apple Mac OS X’ and ‘Version: Mac OS X Server 10.6 64-bit’, then click Continue.

    • Click the “Customize Settings” button, then name and save the new virtual machine.
    • Choose “CDs & DVDs” from Settings, then click “Use disc image” and select your installer image.

    • 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.

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.

nvram.zip

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 begin the installation process.

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.

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.

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 (on Developer 4 “Startup Disk” can actually be found under the  Apple menu).

Step 13 (Optional)

Get sound working.

Once you have run through the setup of OS X Lion and logged in you can now install the VMWare Tools from the “Virtual Machine” menu. Run through the installer and reboot.

Once rebooted, power off the VM and add the Sound card in the Settings for the VM (this can only be done when powered off, suspending the VM will not work).

Start the VM again and download the following Sound driver in to the Lion VM.

Sound Driver

Before you run the installer you must open Terminal to remove the “ServerVersion” plist, otherwise the sound driver installer will report that it needs to be installed on 10.4 or higher. In Terminal type:

sudo rm /System/Library/CoreServices/ServerVersion.plist

Run the sound driver installer package, but when it reaches the end DO NOT restart. If you restart you will receive the VM message that the OS is not the Server Version. Run this command in Terminal to ‘touch’ the ServerVersion.plist again.

sudo touch /System/Library/CoreServices/ServerVersion.plist

Once rebooted sound should now be working.

Print Friendly

About the Author

I'm an enthusiastic technology lover and work daily in a mixed AD/OD IT environment. Like most, I strive to work on the Apple platform and tolerate the Windows one. I also have a burning passion for music/bass playing and supporting my football club, Arsenal. I use this blog to write useful articles on cool Mac things, and other technology experiences - my trials and tribulations.

  • http://www.mactasia.co.uk Simon

    I recently received and email saying that they could not get to the boot menu in Fusion. This was the fix they found:

    Open both the install image and the virtual machine file, then manually showing hidden files, and copying the .plist file into the .vmdk file. (Authenticate in Finder). Then hide the hidden files, close the .vmdk file, and re-start the Lion VM. It works a treat. You might want to post this so that others can benefit.

    • Miguel

      Hi Simon, I Installed mac os x Lion follows the steps above, it was perfect, but the performance itsn’t pretty good, I would try that are you saying about .plist files, let me know how to do that?? I should get them from preferences folder??

      • http://www.mactasia.co.uk Simon

        Hi Miguel, firstly; do you have the VM Tools installed? It’s horrible until those are on… though it will still be dependant on how much processing power and RAM you have assigned to the VM.

  • Mike

    Hi,

    On step nine there is an nvram.zip file that needs to be downloaded, the link seems to be broken. Can you please fix it? Thank You.

    • Simon

      Hi Mike, the file link has now been updated.

  • Ivan

    Hi Simon,

    I followed the steps detailed here and got stuck between steps 9 & 10.

    The error I found on the VMware Fusion file is as follows:

    Boot failed. Mac OS X
    Boot Failed. EFI SCSI Device
    efiboot loaded from device: Acpi(PNP0A03,0) /Pci(11|0) /Pci (0|0) /Scsi (Pun0,Lun0) /CDROM(Entry0)

    boot file path: \System\Library\Core Services\boot.efi
    .Error loading kernelcache (0xe)
    Boot failed. EFI SCSI Device 1

    any idea why it got stuck?

    • Ivan

      Oh nevermind, I found where the mistake was. I made a mistake at step 5. Mispelt kernelcache as kernalcache LOL.

      And yes, copying com.apple.Boot.plist into the VM folder is also a necessary step.

  • Ivan

    Hi Simon,

    Have you tried running youtube videos on your Mac VM? All I get is a transparent “hole” in the browser* window. I can’t see anything, but the audio from the youtube clip plays fine.

    * Tested on Chrome

    • Simon

      Hi Ivan, doesn’t work for me either. Tried Safari and Chrome – both only play sound!

      The next version of Parallels due out soon will support Lion. I expect Fusion will follow suit, so i’m sure it will be resolved with correct support.

      • http://ivan.sg Ivan

        I’ve found a temporary workaround: Right click on the youtube video using Safari, go to Settings and disable hardware acceleration. That would fix the youtube videos, as well as other flash related problems, e.g. Google Analytics graphs. It drives CPU through the roof though.

        By the way, I’d recommend this plugin (Link below):
        Subscribe to Comments
        - Subscribe to Comments allows commenters on an entry to subscribe to e-mail notifications for subsequent comments.

        http://wordpress.org/extend/plugins/subscribe-to-comments/

  • Simon

    Thanks, Ivan. I’ve installed it on your recommendation!

  • BABA

    I managed to get the sound. After installed the EnsonAudio driver, close the VM. Edit the “Mac OS X Lion.VMX file” in windows, add the following lines:

    sound.present = “TRUE”
    sound.virtualDev = “es1371″
    sound.fileName = “-1″
    sound.autodetect = “TRUE”

    • http://www.mactasia.co.uk/ Simon

      Thanks for the info!

  • Nassim.Spider

    thanx the sound works very good !!