Search code examples
vagrantvirtualboxhyper-v

Vagrant synced_folder fmode vs file_mode


Using Vagrant one has to use configs like these for usage with Hyper-V vs Virtualbox:

(Virtualbox)

config.vm.synced_folder ".", "/var/www/btoc/", mount_options: ["fmode=666", "dmode=777"]

(Hyper-V)

config.vm.synced_folder ".", "/var/www/btoc/", mount_options: ["file_mode=0777", "dir_mode=0777"]

The only difference is fmode/dmode vs file_mode/dir_mode.
But this leads to not being startable on respectively the other one. Vagrant up dies with cryptic messages / problems when trying it.

Is there a workaround for this?
Why was this decision made?
Is it simply a bad decision or am I missing something obvious?

Using Vagrant 2.2.3 on Windows.


Solution

  • when you have different settings per provider, you can override the setting in a provider specific section:

    Vagrant.configure("2") do |config|
      config.vm.box = "xxxx"
    
      config.vm.provider "virtualbox" do |vb, override|
        override.vm.synced_folder ".", "/var/www/btoc/", mount_options: ["fmode=666", "dmode=777"]
      end
    
      config.vm.provider "hyperv" do |h, override|
        override.vm.synced_folder ".", "/var/www/btoc/", mount_options: ["file_mode=666", "dir_mode=777"]
      end
    
    end