Creating a never booted OS X template in vSphere 5.1

Page 1 – Introduction and reason for doing this

The goal of this blog post is to produce a never booted installation of OS X Mountain Lion, in a VMDK, which can be used as a template in VMware vSphere vCenter 5.1.

The reason for doing this, is that when a OS X installation is done the normal way, using the Installation GUI, then on the first boot of the newly installed machine there is created a bunch of machine specific files and items.
These machine specific files and items, e.g. the Local Kerberos Key Distribution Center (or LKDC), needs to be cleaned out, if the installation is going to be used as a template, either in VMware vSphere or using traditional image deployment techniques.

Instead of doing the installation using the normal GUI procedures, it is possible to install OS X into an empty DMG image file, and therefor the installed version of OS X is never booted, and thereby the machine specific files and items are never created. Leaving you with a pristine and untouched version of OS X, ready to be booted for the very first time, when deployed.

During this blog post I will walk you through how to do all this, with detailed instructions and screenshots.

I will be using the following tools and files throughout this blog post:

System Image Creator
This is a BASH script, for installing and configuring a never booted version of OS X into a DMG image file.
It is a free Open Source tool, originally created by Duncan McCracken, at Mondada.com.au
The newest version of the BASH script is available on Github: https://github.com/mondada/SIC

Disk Utility
This is a built in GUI application, ‘Disk Utility.app’, located in ‘/Applications/Utilities/’. It is used for managing hard drives and disk images.

installer
This is a built-in Command Line tool in OS X, which is the CLI equivalent of the GUI ‘Installer.app’. But the CLI version lets you specify the target disk to be install into. In this blog post it will be a mounted Sparseimage file that will be the target.

VMware Fusion
This is VMware’s desktop hypervisor for Mac.
I am not going to be using it in the normal way.
Instead I am going to use some Command Line Utilities included with VMware Fusion. More precisely vmware-rawdiskCreator and vmware-vdiskmanager.
It does not have to be a purchased version of VMware Fusion, a Trial version will work fine in this case.
Obtain VMware Fusion here: http://www.vmware.com/products/fusion/overview.html

VMware Tools for OS X from a ESXi host
VMware Tools for OS X will be install via the Command Line into the never booted version of OS X.

Install OS X Mountain Lion.app
The newest version of “Install OS X Mountain Lion.app”, by buying and downloading “OS X Mountain Lion” from the App Store.
Direct link to App Store: https://itunes.apple.com/en/app/os-x-mountain-lion/id537386512?mt=12

Once downloaded, don’t actual run the installer.
Instead, go into your Applications folder, ‘/Applications’, and locate the app called: ‘Install OS X Mountain Lion’.
Right-click (or CTRL+click) on it, and chose ‘Show Packages Contents’, which will open a new Finder window, revealing the contents of the app.
In this new Finder window, navigate to the following folder:

Contents -> Shared Support

In here is a file called InstallESD.dmg.
This ‘InstallESD.dmg’ file is a “Virtual DVD” for installing Mountain Lion onto either a physical or virtual Mac.

Post-370-01-Finder-InstallESD

This blog post consists of the following pages:

17 thoughts on “Creating a never booted OS X template in vSphere 5.1

  1. Frank Muller

    Maybe a stupid question, but this will only work when you are using Apple Hardware to run vCenter right?

    Or does this work on vCenter under Non-apple hardware?

    Interesting write-up by the way :-)

     

    Reply
    1. Mads Fog Albrechtslund Post author

      Yes, that is completely correct.
      According to the Apple EULA, OS X is only allowed on Apple-branded Hardware.
      VMware (and Apple) have made a hardware-check in ESXi, which identifies when ESXi is running on Apple-branded Hardware,
      and thereby allowing the start/running of OS X guest.
      You can mix “PC” hardware and Apple hardware in a cluster, but you can’t migrate a OS X guest to a non Apple-branded piece of hardware in the cluster.
      The Apple-branded Hardware on the other hand, can run all the guest OSes, that the “PC” hardware can run.

      Reply
  2. Jason Bush

    Thank you for this writeup. I’m getting an error Unable to create the source raw disk: The specified is not a valid physical disk device. when I run ./vmware-rawdiskCreator create /dev/disk2 fullDevice /Users/mads/Desktop/OS-X-Template-link lsilogic Any ideas what the cause would be?

    Reply
    1. Mads Fog Albrechtslund Post author

      Hi Jason

      If that is the command, you are trying to run, then you need to modify it to your own computer setup.

      This works on my computer, because my account is called ‘mads’ and because the Sparseimage Disk Number is ‘disk2′.
      ./vmware-rawdiskCreator create /dev/disk2 fullDevice /Users/mads/Desktop/OS-X-Template-link lsilogic

      If your account is named ‘jason’ and the Sparseimage Disk Number on your computer is like ‘disk3′, then the command should look like this:
      ./vmware-rawdiskCreator create /dev/disk3 fullDevice /Users/jason/Desktop/OS-X-Template-link lsilogic

      Hope that helps you to get it to work.

      Reply
  3. Nico Van der Meirsch

    Nice to read that we aren’t the only ones, which running a VMWare environment on Mac.  Still two behaviours/issues we discover in our current “VMware ESXi, 5.1.0, 1117900″ setup, are following items:

    vmwaretools stop running on moment of user logout
    extending of a VM Hard disk can’t be fulfilled on Mac OS level

    Don’t know if this issues are local to our setup, or if you see familiar behaviour at your site?

    Reply
    1. Mads Fog Albrechtslund Post author

      Hi Nico

      I haven’t noticed any problems with vmwaretools on user logout, but then again must of my OS X VM’s don’t get logged out.

      I have also have trouble extending a HFS+ partition on a VMDK, inside a OS X VM.
      Both a boot-partition and a simple data partition.
      I haven’t found a way to do it, yet.

      Reply
  4. Dave

    Love the guide.  Very helpful!

    Quick question:  Is there any way to incorporate within the template the setting to always boot in verbose mode?  The only way I know how to do this is to boot the OS and run nvram boot-args="-v" in Terminal.

    My only thought is to try to mess with the *.nvram file within the template – but this is not stored in a plaintext format.

    Any other ideas?

     

    Thanks in advance.

    Reply
    1. Mads Fog Albrechtslund Post author

      Hi Dave

      Thanks for the comment.

      Yes, it should be possible.

      Before converting the Sparseimage to VMDK format, you will need to edit the ‘com.apple.Boot.plist’ file.
      The file is located here:
      /Library/Preferences/SystemConfiguration/com.apple.Boot.plist

      You should add ‘-v’ in the string block of the ‘Kernel Flags’, like this:

      This should tell the VM’s deployed from the template to always boot in verbose mode.

      I have not tried to change this in the template, but I have used it a few times, on individual OS X based VM’s.

      More info about com.apple.Boot.plist:

      http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man5/com.apple.Boot.plist.5.html

      Hope this helps.

      Reply
  5. Dave

    Thanks! This looks perfect.

    One more tweak that I was wondering about and thought might be useful for readers of this page:

    Any way to modify template to change default screensaver from Flurry to FloatingMessage? We have a problem with very high CPU usage on our VMs when Flurry activates. The saver used at login screen is tied to the preference for root user so in the past, I have (after deploy), logged in as root and changed there.

    I suppose I could simply delete /System/Library/Screen Savers/Flurry.saver and symlink FloatingMessage.saver to that file, but I thought there might be a better way.

    Again, thanks in advance.

    Reply
    1. Mads Fog Albrechtslund Post author

      My suggestion is to try and change the preference related to the screensaver at the login window, with something like this:

      sudo defaults write /path to your mounted sparseimage/Library/Preferences/com.apple.screensaver loginWindowIdleTime 0

      It should tell the OS X VM’s deployed from the template, not to start the screensaver while being idle at the login window.

      I have not testing this completely, but it seems to work, as far as I can tell.

      You would would properly have to do something similarly to the ‘admin’ user created by SIC, but I haven’t found a way to do that to the Template.
      Because the ‘admin’ screensaver settings are controlled via the ByHost preferences, which needs the IOPlatformUUID, which don’t exist yet, because the Template has never been booted. (I may be wrong here, its late, and I may not be thinking straight :-) )

      Reply
  6. tom

    Nice and detailed guide.
    I’m getting an error

    VixDiskLib: Invalid configuration file parameter. Failed to read configuration file.
    Creating disk ‘/Users/tomillo/Desktop/OS-X-Template.vmdk’
    Failed to convert disk: The system cannot find the file specified (0x1900000004)

    Any ideas?

    Reply
    1. Mads Fog Albrechtslund Post author

      Hi Tom

      I have not seen that error before. So no I don’t have any ideas.

      When are you seeing this error, in the complete process?

      Reply
  7. John Lockwood

    It seems to me that this solution is basically the same as that used by InstaDMG (a command line tool), or AutoDMG (a GUI tool) with AutoDMG being considered a successor to InstaDMG.

    See https://code.google.com/p/instadmg/

    and https://github.com/MagerValp/AutoDMG

    Is there any important difference between SIC from Mondada or these tools? I already use AutoDMG along with DeployStudio.

    Reply
    1. Mads Fog Albrechtslund Post author

      Hi John

      Thanks for you comment, and sorry for the late reply.

      As far as I know, InstaDMG and AutoDMG primarily just creates a installed OS with the default settings.

      Neither of them, have the possibilities to customize the installed OS, like SIC does.
      One could of cause customize the outputted DMG from InstaDMG or AutoDMG, or maybe use a tool to do this.
      But I am not aware of such a tool, that can customize a OS in a DMG, without deploying the DMG to a machine.
      If such a tool exist, I would like to know about it.

      Reply
    1. Mads Fog Albrechtslund Post author

      Hi Pavel

      I am not the developer of the SIC tool, just another user.

      The developer is Duncan McCracken over at http://www.mondada.com.au, but I don’t think he is maintaining/actively developing the SIC tool anymore.

      There are some other tools, that do some of the stuff the SIC tool did/does, like AutoDMG (https://github.com/MagerValp/AutoDMG) and CreateUuserPkg (http://magervalp.github.io/CreateUserPkg/ or in the App Store).
      Both tools are developed by Per Olofsson (https://twitter.com/MagerValp).

      AutoDMG installs OS X into a DMG, and lets you add .pkg packages into it.
      CreateUserPkg is a tool to create a package that “installs” a User account, which can then be used as a Package for AutoDMG.

      What neither of those tools do, is the “customization” part of the SIC tool.
      I am not aware of any current/up-to-date tool that can do that to OS X installed into a DMG.
      But I would liek to know, if there is such a tool available somewhere.

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">