2015-11-06 Creating an OS X virtual machine

Automatically creating an OS X virtual machine is getting quite easy and automated nowadays.

If you haven't installed Homebrew, install it according to the command shown at http://brew.sh

Additionally, install Homebrew Cask:

  $ brew install caskroom/cask/brew-cask

Then install packer. If you haven't used packer before, it's a tool for automating the creation of Virtual Machine images.

  $ brew install packer

And via Cask, install vagrant and VirtualBox. Vagrant is a tool for managing development environments using Virtual Machines, i.e. starting, stopping et cetera.

  $ brew cask install vagrant
  $ brew cask install virtualbox

Now continue with rmoriz' instructions.

Check the results:

  $ vagrant box list
  macosx-10.10 (virtualbox, 0)

Initialize vagrant and start the VM:

  $ vagrant init macosx-10.10
  A `Vagrantfile` has been placed in this directory. You are now
  ready to `vagrant up` your first virtual environment! Please read
  the comments in the Vagrantfile as well as documentation on 
  `vagrantup.com` for more information on using Vagrant.

Now open the file Vagrantfile with an editor and search for the line:

  config.vm.box = "macosx-10.10"

Below, add the following lines:

  config.vm.provider "virtualbox" do |vb|
    config.vm.synced_folder ".", "/vagrant", type: "rsync"
  end

Then start the VM:

 $ vagrant up
 Bringing machine 'default' up with 'virtualbox' provider...

See if it's really running:

  $ vagrant ssh
  Last login: Fri Nov  6 04:17:05 2015
  osx-10_11:~ vagrant$ uname -a
  Darwin osx-10_11.vagrantup.com 15.0.0 Darwin Kernel Version 15.0.0: Sat Sep 19 15:53:46 PDT 2015; root:xnu-3247.10.11~1/RELEASE_X86_64 x86_64

Alternatively, start VirtualBox, select the VM on the left side and click the Show button.

VirtualBox.png

OSX Virtual Machine.png

Congratulations! Have a drink 🍻