Create a Ubuntu Server 12.04 LTS Vagrant Base Box from Scratch Using VMware Fusion

• Updated March 17, 2019

Vagrant makes it easy to spin-up local virtual machines using VirtualBox or VMware Fusion. There are many Vagrant Boxes available to use immediately after downloading and installing Vagrant. However, I prefer to know exactly how my virtual machine image is created. This post will walk you through creating a Ubuntu Server 12.04.4 LTS Vagrant Base Box from scratch using VMware Fusion 5 or 6.

If you prefer VirtualBox to VMware Fusion, read how to create a Ubuntu Server 12.04.4 LTS Vagrant Base Box from scratch using VirtualBox.

Install VMware Fusion 5 or 6

Before you begin, you will need to download and install a licensed copy of VMware Fusion 5 or 6 which costs $59.99 (there is a 30 day free trial available).

Install Vagrant and the Vagrant VMware Provider License

Next, download and install the latest version of Vagrant for OS X.

In addition, you will need to purchase the Vagrant VMware Provider License from HashiCorp, the creators of Vagrant, for $79.00 here. This provider license is what allows Vagrant to talk to VMware Fusion.

Once Vagrant is installed, open the Terminal application and download and install the Vagrant VMware Fusion Provider plugin:

vagrant plugin install vagrant-vmware-fusion

HashiCorp should have emailed you the Vagrant VMware Fusion Provider License by now. License the provider with the following command (save the license in a safe place, Vagrant will copy the license to it’s own directory as well):

vagrant plugin license vagrant-vmware-fusion ~/Downloads/license.lic

Verify everything is working by running any of the Vagrant commands. An error message will be thrown if there is something wrong.

Prepare the Ubuntu Server 12.04.4 LTS Virtual Machine

The following steps were written for VMware Fusion 6. They may differ if you are using VMware Fusion 5.

  1. Download Ubuntu Server 12.04.4 LTS.
  2. Open VMware Fusion, go to File > New….
  3. Click Continue without disc.
  4. Click Choose a disc or disc image.
  5. Choose the downloaded ubuntu-12.04.4-server-amd64.iso, click Open, and Continue.
  6. Set Operating System to Linux and Version to Ubuntu 64-bit and click Continue.
  7. Uncheck Easy Install and click Continue.
  8. Click Customize Settings.
  9. Save your virtual machine with whatever name you like, I chose ubuntu-server-12.04.4-lts-x86_64.vmwarevm, and click Save.
  10. The Settings pane should then appear.
  11. Under Sharing, turn Shared Folders Off.
  12. Under Processors & Memory, set Processors to 1, Memory to 512 (Vagrant can change these values later), expand Advanced options and check Enable hypervisor applications in this virtual machine.
  13. Under Display, turn Accelerate 3D Graphics Off.
  14. Under Network Adapter, make sure Share with my Mac is selected.
  15. Under Hard Disk (SCSI), set the Disk size to 40.00 GB, expand Advanced options and uncheck Split into 2 GB files, then click Apply.
  16. Under CD/DVD, expand Advanced options, and change the Bus type to IDE.
  17. Under Sound Card, click Remove Sound Card.
  18. Under USB & Bluetooth, expand Advanced USB options, click Remove USB Controller, and click Remove.
  19. Under Printer, click Remove Printer Port, and click Remove.
  20. Under Compatibility, expand Advanced options, change the Use Hardware Version to 9, uncheck Allow upgrading the virtual hardware for this virtual machine, and click Apply.
  21. Under Isolation, uncheck Enable Drag and Drop and Enable Copy and Paste.
  22. Close the Settings menu.
  23. Start up the virtual machine and begin installation.

Install Ubuntu Server 12.04.4 LTS

You can install the operating system manually, using a Ubuntu Preseed file, or using a Kickstart Profile. I will be providing steps to install the operating system manually and using a Kickstart Profile.

Take note, no where in the following steps do I install VMware Tools. So far, I have not found a need for them. Feel free to install VMware Tools if you need them.

Follow the steps in one of the following two sections, Manual Installation or Kickstart Profile Installation.

Manual Installation

Install the operating system however you like. Most of the default options can be used.

Once the operating system has finished installing and booted, perform the following post-install steps to make it work with Vagrant.

Login as the vagrant user (password is vagrant).

Install additional repository packages:

sudo apt-get install openssh-client wget curl git man vim ntp

Allow user vagrant to use sudo without entering a password:

sudo bash -c 'echo "vagrant ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers'

Create the .ssh keys folder:

mkdir -m 0700 -p /home/vagrant/.ssh

If you want to use your own SSH public/private key then create an SSH public/private key on your workstation (you may already have), and copy the public key to /home/vagrant/.ssh/authorized_keys on the virtual machine.

Otherwise, if you want to use the SSH public/private key provided by Vagrant, run the following command:

curl >> /home/vagrant/.ssh/authorized_keys

Clean up apt:

sudo apt-get clean

Clean up the tmp directory:

sudo rm -rf /tmp/*

Clean up the last logged in users logs:

sudo rm -f /var/log/wtmp /var/log/btmp

Clean up history:

history -c

sudo history -c

Shutdown the virtual machine:

sudo shutdown -h now

Once the virtual machine is shutdown, open Settings for the virtual machine.

Click the CD/DVD (IDE) button, expand Advanced options, click Remove CD/DVD Drive, and click Remove.

Close the Settings menu.

Next, jump to the Create the Vagrant Box section.

Kickstart Profile Installation

I used this Kickstart Profile to automate the build.

Start up the virtual machine and when the Ubuntu boot menu appears, select your language, hit the F6 key to bring up Other Options, hit the Esc key, and append the following:


Hit the Enter key and wait for the installation to finish.

At the end of the install, shutdown the virtual machine, and again open the Settings for the virtual machine.

Click the CD/DVD (IDE) button, expand Advanced options, click Remove CD/DVD Drive, and click Remove.

Close the Settings menu.

Next, jump to the Create the Vagrant Box section.

Create the Vagrant Box

Go to the directory where your virtual machines are stored. By default this will be ~/Documents/Virtual\ Machines or ~/Documents/Virtual\ Machines.localized. In my case it was the latter.

cd ~/Documents/Virtual\ Machines.localized/ubuntu-server-12.04.4-lts-x86_64.vmwarevm

Defrag and shrink the VMDK as much as possible:

/Applications/VMware\ -d Virtual\ Disk.vmdk

/Applications/VMware\ -k Virtual\ Disk.vmdk

Stay in the current directory, and add a metadata.json file with the following contents:

    "provider": "vmware_fusion"

Remove the VMware log files:

rm -f vmware*.log

Finally, tar everything up into a box file:

tar cvzf ./*

Remove the metadata.json file:

rm -f metadata.json

Adding the Vagrant Box

Vagrant appears to have problems with spaces in absolute paths, so move the Vagrant Box somewhere else:

mv ~/Desktop

Add the newly created Vagrant Box to vagrant (this will copy the Vagrant Box to another location):

vagrant box add ubuntu-server-12.04.4-lts-x86_64 ~/Desktop/

Once the Vagrant Box has been copied, the original Vagrant Box file can be deleted:

rm -f ~/Desktop/

In addition, the VMware Fusion virtual machine can be deleted.

Create a Vagrant Project and Configure Vagrantfile

You can have as many vagrant projects as you want. Each will contain different Vagrantfiles and different virtual machines. So, create a directory somewhere to house your Vagrantfile and associative virtual machines:

mkdir -p ~/Development/vagrant-test

cd ~/Development/vagrant-test

Create the Vagrantfile:

vagrant init ubuntu-server-12.04.4-lts-x86_64

You now have a Vagrantfile that points to the ubuntu-server-12.04.4-lts-x86_64 Base Box you just created.

If you are using your own SSH private/public key, and not the SSH private/public key provided by Vagrant, you need to tell Vagrantfile where to find your SSH private key, so add the following to your Vagrantfile:

config.ssh.private_key_path = "~/.ssh/id_rsa"

Lastly, if you do not want Shared Folders setup between your workstation and virtual machine, disable it by adding the following to your Vagrantfile:

config.vm.synced_folder ".", "/vagrant", id: "vagrant-root", disabled: true

Start Using Vagrant

Spin up your first virtual machine:

vagrant up --provider vmware_fusion

If everything spins up properly you can see the status of your virtual machine using vagrant status, you can SSH into your virtual machine using vagrant ssh, or you can destroy your virtual machine using vagrant destroy.


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.