Long ago when Leopard was launched, the end-user license agreement allowed Leopard Server to be virtualized. Same applied for Snow Leopard Server.
However now with Lion's launch, things have changed:
(iii) to install, use and run up to two (2) additional copies or instances of the Apple Software within virtual operating system environments on each Mac Computer you own or control that is already running the Apple Software.
As extracted from Mac OS X 10.7 end-user license agreement, that you can read here.
So now, beside that legal sentence is the meaning that you can run up to a maximum of three copies of Mac OS X Lion, one running real on bare hardware and two running inside a virtual machine.
VMWare Fusion added support to Mac OS X Server as a guest with Leopard Server, however it still has added no official support for Lion.
In this guide I'll explain you how to install it correctly.
First of all you need to be sure you have the lastest version (3.1.3 as of this writing) installed. You can get it here.
I have tested this on both Snow Leopard and Lion hosts.
Second of all you need the Lion Emergency Startup Disk, in image, USB or burnt (you can see where it is, called InstallESD.dmg, here).
Third of all we'll create an installer image, so go to Utilities (Cmd+Shift+U on Finder), open Disk Utility and create a new image with the following parameters:
Now insert or mount Lion ESD. We need now to go to the Terminal (open it in Utilities) and start with command:
hdiutil mount "/Volumes/Mac OS X Install ESD/BaseSystem.dmg"
Now a new drive will appear mounted, called "Mac OS X Base System" and we return to disk utility to copy this volume to the disk image we created earlier.
Be sure to have marked "Erase destination". After a couple of minutes we will have two disks called "Mac OS X Base System", that should be unmounted. Then double click the LionVMInstaller.cdr image and go to Terminal.
First we will copy the kernel cache from ESD to our installer image:
sudo cp /Volumes/Mac\ OS\ X\ Install\ ESD/kernelcache /Volumes/Mac\ OS\ X\ Base\ System/
And now we instruct the prepared image to use it, editing boot parameters, using nano, a text editor in Terminal:
sudo nano /Volumes/Mac\ OS\ X\ Base\ System/Library/Preferences/SystemConfiguration/com.apple.Boot.plist
And we write
Just before </dict> so it ends like this:
Now with pressing Ctrl+X keys it will ask to save, we press Y as in Yes and it's done.
Next step is copying installation packages from the ESD to the prepared image with the following two commands:
sudo rm /Volumes/Mac\ OS\ X\ Base\ System/System/Installation/Packages/
sudo cp -Rv "/Volumes/Mac OS X Install ESD/Packages" "/Volumes/Mac OS X Base System/System/Installation/Packages"
And now we create a file to make VMWare Fusion think this disk comes from a Server version, as it will expect.
sudo touch "/Volumes/Mac OS X Base System/System/Library/CoreServices/ServerVersion.plist"
And enough of the terminal for now. We unmount everything, start VMWare Fusion and create a new virtual machine.
We choose LionVMInstaller.cdr as the image to install from, and in case it does not detect it's Mac OS X, we choose as operating system "Apple Mac OS X" and as version "Mac OS X Server 10.6 64-bit".
Be sure to customize settings, then it will ask for the name. I named it "Mac OS X 10.7 Lion". Now choose Hard Disks and uncheck "Split into 2 Gb files" and Apply.
Go to Processors & RAM and put at least 2048 Mb and as more as you want and can.
It will crash, this is expected. For some reason the NVRAM values VMWare writes by default don't allow Lion to boot. Download a prepared NVRAM here.
In VMWare right click the virtual machine, "Show in Finder", right click it, "Show Package Contents", and replace the NVRAM file there with the one you just downloaded.
Go to VMWare Fusion and boot it again.
Now follow the installation instructions. When it finishes and reboots VMWare will complain it's not a server version, it's ok.
Reboot the virtual machine and as soon as the vmware logo appears in grey press the ESC key FAST!.
A menu will appear, and here we will choose "Boot Manager", that will present us with a list of detected boot devices, mostly the HDD and the prepared image.
Taking note that the first item "Mac OS X" contains the device path of the hard disk, we choose the "EFI SCSI Device" were PCI number or SCSI numbers changed (most probably, "EFI SCSI Device 1").
It will boot the installer again, but this time we will enter on Terminal. Utilities -> Terminal. Now here we write:
touch "/Volumes/Macintosh HD/System/Library/CoreServices/ServerVersion.plist"
IMPORTANT EDIT NOTICE: Some updates, specially Java runtime, will crash if you did this step. Doing this other one will solve it, and can be done in an already installed Lion VM:
sudo cp "/Volumes/Macintosh HD/System/Library/CoreServices/SystemVersion.plist" "/Volumes/Macintosh HD/System/Library/CoreServices/ServerVersion.plist"
When done, Apple menu -> Restart.
Now, enjoy it!!!