ThorneLabs

Customizing Vagrant VMware Fusion Virtual Machines with VMX Parameters

• Updated May 31, 2014


I was recently working with Vagrant and the Vagrant VMware Fusion Provider Plugin to add a secondary NIC on-the-fly. Vagrant provides functionality to easily add a secondary NIC but you are required to assign it to a network. I didn’t want to assign it to any network, I just wanted the secondary NIC present.

The Vagrant VMware Fusion Provider Plugin has the ability to modify VMware Fusion virtual machines through the use of VMX customization, but according to the Vagrant docs:

VMX is an undocumented format and there is no official reference for the available keys and values.

So, where do you find all of the VMX parameters that you can use if they are undocumented? The answer is actually very simple.

Fire up VMware Fusion and create a VMware Fusion virtual machine (but do not start it). Customize the virtual machine however you like. Assuming you named the virtual machine vm1, navigate to the default location where the vm1 virtual machine is stored: cd ~/Documents/Virtual\ Machines/vm1.vmwarevm or cd ~/Documents/Virtual\ Machines.localized/vm1.vmwarevm. Now that you are in the container directory for the virtual machine you just created, open the vm1.vmx file. This file contains all of the VMX parameters that apply to the virtual machine; if there is a parameter in the VMX file you can customize it through Vagrant on-the-fly.

However, not every VMX parameter will be present in the VMX file. For example, as mentioned above, I wanted to add a secondary NIC, but in the vm1.vmx file there were only entries for ethernet0. Common sense tells me a secondary NIC will probably be ethernet1, so how do I get those entries into the VMX file?

Fire up VMware Fusion again, go to the Settings of the vm1 virtual machine, click Add Device…, select Network Adapter, click Add…, select Private to my Mac, and close the Settings window. Now there is a secondary NIC assigned to the virtual machine. Open the vm1.vmx file again and search for ethernet1. You should now have the following parameters:

ethernet1.present = "TRUE"
ethernet1.connectionType = "hostonly"
ethernet1.virtualDev = "e1000"
ethernet1.wakeOnPcktRcv = "FALSE"
ethernet1.addressType = "generated"

These parameters can be put into your Vagrantfile to add a secondary NIC on-the-fly. This is how the Vagrantfile would look:

# -*- mode: ruby -*- 

# vi: set ft=ruby :

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

  config.vm.box = "precise64"

  config.vm.provider "vmware_fusion" do |v|
    v.vmx["ethernet1.present"] = "TRUE"
    v.vmx["ethernet1.connectionType"] = "hostonly"
    v.vmx["ethernet1.virtualDev"] = "e1000"
    v.vmx["ethernet1.wakeOnPcktRcv"] = "FALSE"
    v.vmx["ethernet1.addressType"] = "generated"
    
  end
end

After running vagrant up --provider vmware_fusion you should be able to login via vagrant ssh and run ifconfig eth1 to see your secondary NIC present but not assigned to any network.

References

If you found this post useful and would like to help support this site - and get something for yourself - sign up for any of the services listed below through the provided affiliate links. I will receive a referral payment from any of the services you sign-up for.

Get faster shipping and more with Amazon Prime: About to order something from Amazon but want to get more value out of the money you would normally pay for shipping? Sign-up for a free 30-day trial of Amazon Prime to get free two-day shipping, access to thousands of movies and TV shows, and more.

Thanks for reading and take care.