Creating an OS X VMware image using Packer

The time has come to look at OS X VMs. I’d put this off for a while as the amount of development I’d have to do on OS X didn’t warrant the effort. But curiosity, easier management of upgrades and the need to learn new things has spurred me on this path of learning.

So without attempting to chew too much in one go my first attempt is to create a VM image using Packer.

Why Packer? From one config you can create images for different platforms – like VMware, VirtualBox, AWS etc.

For my own learnings I was creating images for VMware.

Prerequisites

  1. Have packer installed. If using homebrew simply run
  2. Have VMware Fusion or Fusion Pro installed
  3. Clone the os-x-vm-template project
  4. Have the installation file of OS X available. If you don’t you can download it as follows:
    • Open App Store
    • Search for the OS – in my case I looked for ‘os x yosemite’
    • Click download. It’ll download to /Applications

Creating the image

  1. Go to wherever you cloned the os-x-vm-template project.
  2. Run the prepare_iso.sh script

    This will finish and chuck out some output similar to:
  3. Copy the template.json file in the packer directory
  4. Open the osx-template-vm-ware-iso.json file and:
    • Remove the builder entries for parallels-iso and virtualbox-iso.
    • Modify the iso_checksum and iso_url variable values to match the ones spat out in Step 2. E.g.:
  5. Validate that your config file looks okay:
  6. If your template is all good the next step is to create the image

    This step will take a while as it’ll create a new VM, install and configure OS X then export it as a new vm. The output will be created in a folder of the same name prefixed with output – e.g. output-vmware-iso.

Next up I’ll look at using this image as the image as the base source image to create other more specific images. Why do I want to do this? I want the ability to easy trash and recreate OS X environments but I want this to occur fairly quickly. By keeping a base source image I won’t need to sit through the OS X installation each time I need to start with a ‘fresh’ VM.

Leave a Reply

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