Situation
If you use Fedora distribution on your host machine and you configure your vagrant box to use NFS type of synced folders, you might get into trouble with vagrant hanging during mounting of those NFS shared folders.$ vagrant up ... ... ==> default: Mounting NFS shared folders...
Verify if the firewall configuration is the problem
If you haven't changed default firewall settings, the problem is probably there because Fedora has pretty securely configured firewall by default.
To quickly check if the problem is in the firewall settings you can try to disable it:
sudo systemctl stop firewalld
If you want to double check that firewall is really disabled, you can check iptables rules. Disabled firewall looks like this:
$ sudo iptables -L Chain INPUT (policy ACCEPT) target prot opt source destination Chain FORWARD (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination
But of course disabling the firewall permanently is not a good idea so let's configure it that it allows mounting of NFS folders for the vagrant box.
Don't forget to enable the firewall again:
sudo systemctl start firewalld
Virtualbox network interfaces and fedora firewall
By default Virtualbox uses network interface vboxnet0 but when you reload your vagrant box it might happen that new interface will be created and used by the box (vboxnet1, vboxnet2 etc). So if you see hanged mounting in the future, check if the box uses interface which is allowed in the firewall config.
As I described in my older article about fedora firewall, fedora uses zones into which you assign network interfaces and then you set specific configuration for each zone.
Therefore what we need to do is to assign vboxnet0 (vboxnet1,...) interface into zone "internal" and then allow apropriate ports (services). We can do it via GUI firewall-config or via terminal firewall-cmd.
As clicking into the gui is something what you can probably handle by yourself, I will use the terminal. Another advantage of firewall-cmd is that you can simply copy following commands and paste them intoto your terminal so it's much quicker.
If you do this when nfs directory mounting is hanged you can see that mounting will continue just after you reload the firewall settings.
As I described in my older article about fedora firewall, fedora uses zones into which you assign network interfaces and then you set specific configuration for each zone.
Therefore what we need to do is to assign vboxnet0 (vboxnet1,...) interface into zone "internal" and then allow apropriate ports (services). We can do it via GUI firewall-config or via terminal firewall-cmd.
As clicking into the gui is something what you can probably handle by yourself, I will use the terminal. Another advantage of firewall-cmd is that you can simply copy following commands and paste them intoto your terminal so it's much quicker.
Change the firewall settings to allow NFS mount
sudo su firewall-cmd --zone internal --add-interface vboxnet0 firewall-cmd --permanent --zone internal --add-service nfs firewall-cmd --permanent --zone internal --add-service rpc-bind firewall-cmd --permanent --zone internal --add-service mountd firewall-cmd --permanent --zone internal --add-port 2049/udp firewall-cmd --reload
If you do this when nfs directory mounting is hanged you can see that mounting will continue just after you reload the firewall settings.
==> default: Mounting NFS shared folders... ==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision` ==> default: flag to force provisioning. Provisioners marked to run always will still run.
If you got troubles to make it work, just leave a comment and I will try to help.
That saved my day!!! Thank you so much man!
ReplyDeleteYou're welcome ;)
DeleteThis comment has been removed by a blog administrator.
ReplyDeleteYou my friend, just saved my life. Please can you change the title to how to fix vagrant hanging when mounting folders on fedora.
ReplyDeleteHi Gideon, I'm glad it helped you. I've updated the title.
Delete