How to configure Ubuntu w/ nested virtualization using Vagrant and Virtualbox on MacOS

If you are taking advanced operating systems course at Georgia Tech (OMSCS) and want to run the the lab environment on your mac laptop (or desktop) using Virtualbox, then follow the below instructions. Below, you’ll find a Vagrantfile that will launch a virtual machine, install Ubuntu and configure nested virtualization:

Virtual box w/ nested virtualization
Virtual box w/ nested virtualization

 

Step by Step Instructions

  1. Download and Install latest version of Virtualbox for MacOS1
    1. https://download.virtualbox.org/virtualbox/6.1.12/VirtualBox-6.1.12-139181-OSX.dmg
  2. Download and install Vagrant
    1. https://releases.hashicorp.com/vagrant/2.2.9/vagrant_2.2.9_x86_64.dmg
  3. Create Vagrantfile
    1. mkdir -p ~/workspace/advanced-os-vm && cd ~/workspace/advanced-os-vm
    2. Copy and paste the Vagrant file contents (inspired by another blog post2)
      # https://app.vagrantup.com/ubuntu/boxes/trusty64
      Vagrant.configure("2") do |config|
        config.vm.box = "ubuntu/trusty64"
        # enable nested virtualization
        config.vm.provider "virtualbox" do |vb|
          vb.customize ['modifyvm', :id, '--nested-hw-virt', 'on']
        end
      end

       

  4. Launch virtual machine
    1. Execute vagrant up

Compiling pre-lab

  1. Copy prelab.tar to ~/workspace/advanced-os-vm
  2. Log into your vm
    1. Execute vagrant-ssh
vagrant@vagrant-ubuntu-trusty-64:~$ cd /vagrant
vagrant@vagrant-ubuntu-trusty-64:/vagrant$ tar xvf prelab.tar 
prelab/
prelab/Makefile
prelab/producer_consumer.c
vagrant@vagrant-ubuntu-trusty-64:/vagrant$ make
make: *** No targets specified and no makefile found.  Stop.

References

1. Make sure you are running a version that’s >= 6.1.8 to avoid being bitten by a potential bug that’s reported here: https://www.virtualbox.org/ticket/19245

2. Code snippet for Vagrantfile largely is a derivative of what I found here: https://eclipsys.ca/how-to-enable-nested-virtualization-in-virtualbox-new-feature/