Creating an un-configured OS X Lion Server VM

I wanted to set up a virtual machine that starts up just like that freshly unboxed Mac Mini server, with server assistant and all. Not for any particular reason,  just for the ease of use and fun of it.

As it were, VMware Fusion 4 removed some potentially handy tools for such a job, like mounting a vmdk, but without going into those details and getting vmdk's to mount... there happens to be a rather simple way to get this done!

First lets take a look at what you need for creating an un-configured Lion Server image.

1. OS X Lion Server and the "Install Mac OS X Lion.app" in your /Applications folder. 2. An empty partition/disk called Server HD (can be memory stick or external disk). 3. Active internet connection

Run the Lion Installer and click customise, make sure Server Software is selected, then start the installation. It will initially download the Server Essentials package from Apple, then prep the targeted disk, you'll then have to restart in order for the install to continue. The setup will continue and on the second restart, hold down option/alt and boot back into your original Lion Server.

Now use Disk Utility to create an image of the un-configured Lion Server install. Make sure you scan this image for restore. Once done, copy that image to your VMware Fusion4 host.

{ See HT4746 for more info - Lion Server: Mass Deployment Strategies }

Setting up the Virtual Machine

Fire up VMware Fusion and create a new VM, choose Continue without disc and then Choose a disk or disc image and point to your "Install Mac OS X Lion.app". Proceed through the dialogs and click Customize Settings and save your VM.

Next configure a few settings, specifically Processors & Memory, set to minimum 2 processor cores (credit to @arekdreyer and @andrina). This is really important. If you don't set this, you can't create an Open Directory master/replica, it will just hang and go no-where.

Next add another CD/DVD device, do not mount an image for it yet.

Start your VM up and wait for it to load Lion's setup, now attach the un-configured Lion Server image to the second CD/DVD device you added, then open up a terminal window.

Run 'diskutil list' to get a view of the disks present. At the top of the list will be /dev/disk0 with a volume "Macintosh HD". Locate your un-configured OS X Lion Server image. If you followed everything so far, it should be at /dev/disk14. This step here is only necessary to verify the volume names that you'll specify for the next step.

We'll use Apple System Restore to dump our un-configured image to the VM's hard disk. $ asr restore --source /Volumes/Server\ HD/ --target /Volumes/Macintosh\ HD/ --erase You'll be prompted to erase, press y

Once the restore is done, shutdown the VM completely, disconnect the CD/DVD devices, and guess what you're done! Booting up the VM now will result in a brand new Mac Mini server-like setup experience.