I use Vagrant boxes on Virtualbox for pretty much all my development work these days. Often I need to mount a new shared folder to the box I’m working on, but updating the Vagrantfile and rebooting takes too long to my liking.
It’s much faster to mount with NFS directly when it’s a one-off!
This example assumes that your Vagrant box (or Virtualbox instance) has the IP address
126.96.36.199 and can access the host machine at
If you don’t know the IPs, you can use the
hostname -I command on your Linux guest machine, and
ifconfig | grep inet on your host to look for them. Search for the IPs that are in the same range on both machines.
On your host machine
First edit the
/etc/exports file on your macOS or Linux host. This file defines the list of exported directories and which remote IPs are allowed to access them. Add the following line:
"/Users/stevenrombauts/foobar” 188.8.131.52 -alldirs -mapall=stevenrombauts:staff
This defines a new export for the
/Users/stevenrombauts/myfiles directory. Make sure to put in your username for the
-mapall argument so the NFS server knows which user to map file permissions to on the host.
Now verify the exports file before continuing:
nfsd checkexports && echo "Exports file is valid"
and restart the NFS service to pick up the changes:
sudo nfsd restart
You can use the
showmount command to review all the available NFS mounts on the host:
showmount -e 184.108.40.206
The new entry should be in that list.
On your Linux guest
Make sure that an NFS client is installed on your Linux machine:
cat /proc/filesystems | grep nfs
The output should contain nfs references, for example:
If they’re missing, you’ll need to install the NFS package. You can do so on Ubuntu with
sudo apt-get install nfs-common or on CentOS with
sudo yum install nfs-utils yum install nfs-utils.
Now create the directory where you want to mount the NFS share to:
mkdir -p /home/vagrant/foobar
If it already exists, make sure it’s empty.
Now mount the shared directory. Make sure to replace the host IP and correct the directory paths:
sudo mount -t nfs -v -o rw,vers=3,udp,tcp 220.127.116.11:/Users/stevenrombauts/foobar /home/vagrant/foobar
Check the contents of the mounted directory to make sure the command was successful:
ls -alh /home/vagrant/foobar
For your information, to get the NFS status on the guest machine you can run this command:
All done, ready to continue coding!