Vagrant: how to disable NFS sync folders for a Windows host?

We need to share virtual machines with Linux, MacOS, and Windows hosts. However, NFS sharing is recommended for Linux and MacOS, but NFS sharing is not supported on Windows.

Is there a way to detect that the host system is Windows and disable NFS shares?

+4
source share
1 answer

Vagrant 1.2.5

This actually already takes care of the quality of the roaming 1.2.5, see The option for NFS is not ignored on the host windows and the corresponding b2d1a26 commits (the NFS request in Windows is ignored) :

@__synced_folders.each do |id, options| # Ignore NFS on Windows if options[:nfs] && Vagrant::Util::Platform.windows? options[:nfs] = false end end 

Previous workaround

If you cannot upgrade, you might want to try Ryan Seekely Vagrant and use NFS only for non-Windows hosts :

Well, since Vagrantfile is just a Ruby script, we can just use Ruby! At the top of the Vagrantfile, define:

 def Kernel.is_windows? # Detect if we are running on Windows processor, platform, *rest = RUBY_PLATFORM.split("-") platform == 'mingw32' end 

And then when setting up the shared folder:

 nfs = !Kernel.is_windows? config.vm.share_folder "myfolder", "/srv/www/myfolder.com/", "../", :nfs => nfs 

Please note that I did not actually test this particular solution, but previously used a conceptually similar approach, although I used Vagrant::Util::Platform.windows? as in official commitonics (you don’t need it right now ...).

+6
source

Source: https://habr.com/ru/post/1498912/


All Articles