Running and developing an Ubuntu based workload on Mac OS has never been easier. Canonical has released a new tool called Multipass which allows you to quickly spin up Ubuntu Server virtual machines on Ubuntu, Mac OS and Windows. The following instructions will get you an Ubuntu Server VM up and running, and the Ubuntu file system mounted to Mac OS so that you can work in the Mac OS UI using your regular development tools like VS Code.

Mac OS

You’ll first need to get Multipass installed by visiting the Multipass website and downloading and installing the package on your Mac OS host. Once installed, open the terminal on your Mac OS host and run the following to download and install the latest LTS release of Ubuntu Server.

multipass launch --name ubuntu
multipass shell ubuntu


After the VM has been started we need to connect to it to install the nfs server.

sudo apt install nfs-kernel-server -y

Now we need to create the folder that we’re going to work from in the home directory of our new Ubuntu VM and open up the permissions on it.

mkdir -p ~/code
sudo chmod -R 777 ~/code

This folder needs to be exported from the VM’s file system which is done by appending the following content to the /etc/exports file. If your VM has a different IP range than what is shown below you can simply update the command below to match your environment.

echo "/home/ubuntu/code,fsid=0,insecure,no_subtree_check,all_squash,async,anonuid=1000,anongid=1000)" | sudo tee -a /etc/exports

Then we have to export the folder and restart the NFS service.

sudo exportfs -a
sudo service nfs-kernel-server restart

Create a temporary file so you can see if your mount worked successfully later.

touch ~/code/test

Mac OS

In another terminal window on your Mac OS host we need to mount our VM’s code folder. Replace the string for the VM’s IP address and the UserName of the user on Mac OS.

mkdir -p ~/code
sudo mount -t nfs <VM IP>:/home/ubuntu/code /Users/<UserName>/code

To keep the drive mounted after refreshing and restarting the VM

echo "<VM IP>:/home/ubuntu/code /Users/<UserName>/code nfs resvport,rw,rsize=8192,wsize=8192,timeo=14,intr" | sudo tee -a /etc/fstab

Now you should be able to see the test file that you created previously in Ubuntu from Mac OS.

ls -al ~/code

From the terminal on your Mac OS host you can now open these folders like they live in Mac OS with your code editor of choice.

code ~/code

Tips & Tricks

On a day to day basis the most efficient way to work with these files is to perform your heavy IO interactions like git clones and builds from within your new Ubuntu VM. This can be done by leaving a terminal open SSH’d into it.

The services that Multipass use to create the VM on Mac OS allow you to over subscribe the VM’s resources so if you want to have the fastest VM possible you can give it all CPU cores and RAM as well as ample disk space. The following command will give the new Ubuntu VM 16 cores, 100GB of disk space and 16GB of ram while allowing the host and other Multipass VM’s to share the same resources.

multipass launch -c 16 -d 100G -m 16G --name ubuntu

At the time of writing you cannot resize the VM’s disk space so you’ll want to give it more than you think you’ll need.