I’ve been using Vagrant on and off for years, previously using the virtualbox provider. A while back I started using the libvirt provider instead, mainly because it doesn’t require futzing around with kernel drivers on Fedora like virutalbox does.
One significant difference is how synced directories are implemented. NFS is used by default under libvirt.
So when you write:
Vagrant.configure("2") do |config| config.vm.box = "centos/7" config.vm.synced_folder "www", "/var/www/html" end
Vagrant will create an entry in
/etc/exports on your host machine exposed only to the IP address of the box it creates, and insert an entry into
/etc/fstab on the guest/box.
The default Fedora configuration doesn’t work out of the box (assuming you even have NFS installed on your computer).
These steps worked for me:
dnf install nfs-utils systemctl enable nfs-server firewall-cmd --zone=trusted --add-source 192.168.122.0/24 --permanent firewall-cmd --reload sed -i 's/# udp=n/udp=y/' /etc/nfs.conf systemctl restart nfs-server vagrant up
This assumes you’re using the libvirt NAT network driver, and the range it uses is
Vagrant uses udp which is disabled by default in Fedora (and possibly other distributions). The firewall change may not be required, depending on how your system is configured.
Alternatively, you could switch to TCP mode like so:
config.vm.synced_folder "www", "/var/www/html", nfs_udp: false
This has some performance implication, so your use case will inform which option you go for. The NFS documentation has some further details.