Vagrant: Vagrant is Unable To Create Synced Folders On Windows Host HyperV Provider

Created on 10 Nov 2017  ยท  9Comments  ยท  Source: hashicorp/vagrant

Vagrant version

vagrant -v
Vagrant 2.0.1

Host operating system

Microsoft Windows 10 Version 1703

Guest operating system

Centos 6.9 Final (Official Box from Centos)

Vagrantfile

# -*- mode: ruby -*-
# vi: set ft=ruby :

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
  # The most common configuration options are documented and commented below.
  # For a complete reference, please see the online documentation at
  # https://docs.vagrantup.com.

  # Every Vagrant development environment requires a box. You can search for
  # boxes at https://vagrantcloud.com/search.
  config.vm.box = "Test"
  #config.ssh.insert_key = true
  #config.ssh.username = 'root'
  #config.ssh.password = 'vagrant'
  config.ssh.private_key_path = ["../Keys/PrivateKey/privatekey06112017"]

  # Disable automatic box update checking. If you disable this, then
  # boxes will only be checked for updates when the user runs
  # `vagrant box outdated`. This is not recommended.
  # config.vm.box_check_update = false

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine. In the example below,
  # accessing "localhost:8080" will access port 80 on the guest machine.
  # NOTE: This will enable public access to the opened port
  # config.vm.network "forwarded_port", guest: 80, host: 8080

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine and only allow access
  # via 127.0.0.1 to disable public access
  # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"

  # Setting Up Hostname
  config.vm.hostname = "Test"
  # Create a private network, which allows host-only access to the machine
  # using a specific IP.
  # config.vm.network "private_network", ip: "192.168.3.55"

  # Create a public network, which generally matched to bridged network.
  # Bridged networks make the machine appear as another physical device on
  # your network.
  # config.vm.network "public_network"

  # Share an additional folder to the guest VM. The first argument is
  # the path on the host to the actual folder. The second argument is
  # the path on the guest to mount the folder. And the optional third
  # argument is a set of non-required options.
  # config.vm.synced_folder "../data", "/vagrant_data"
  config.vm.synced_folder "../TRepo", "/home/dev/html/TRepo", create: true, mount_options: ["vers=3.0"]

  # Provider-specific configuration so you can fine-tune various
  # backing providers for Vagrant. These expose provider-specific options.
  # Example for VirtualBox:
  #
  # config.vm.provider "virtualbox" do |vb|
  #   # Display the VirtualBox GUI when booting the machine
  #   vb.gui = true
  #
  #   # Customize the amount of memory on the VM:
  #   vb.memory = "1024"
  # end
  #
  # View the documentation for the provider you are using for more
  # information on available options.

  # Enable provisioning with a shell script. Additional provisioners such as
  # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
  # documentation for more information about their specific syntax and use.
  # config.vm.provision "shell", inline: <<-SHELL
  #   apt-get update
  #   apt-get install -y apache2
  # SHELL
end

Debug output

Failed to mount folders in Linux guest. This is usually because
the "vboxsf" file system is not available. Please verify that
the guest additions are properly installed in the guest and
can work properly. The command attempted was:

mount -t cifs -o uid=500,gid=500,vers=3.0,sec=ntlm,credentials=/etc/smb_creds_b6cac76264e7654e16e25c9ffef7b203 //192.168.3.51/b6cac76264e7654e16e25c9ffef7b203 /home/dev/html/Trepo

The error output from the last command was:

mount error(112): Host is down
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)

Expected behavior

It Should have successfully mounted

Actual behavior

As You can see i am getting mount error(112): Host is down.
I have tried many solutions from other issues.
1) Tried SMB v2 and v3 Both
2) Tried Using Command smbclient //ip.add.rre.ss/ -m SMB3 -U Username
Nothing worked.

Steps to reproduce

  1. Use The Default centos/6 Box .
  2. yum install cifs-utils
  3. and Vagrant up

Note

I also Tried official centos 7 box which can easily setup synced folders just after installing cifs-util and using a local admin account on windows 10.

Update 12/11/2017
initially i had smbclient 3.6 installed on centos 6 , now i have managed to install smbclient 4.4 on centos and now this time smbclient can connect to the Windows share but mount -t command still shows "host Down " error . That's annoying.

Update 2
Now I have updated Cifs-utils to latest version making mount.cifs latest 6.7 . Turned On Debugging Of cifs. and here is the Log.
https://gist.github.com/SSoft7/7f8c1b4d5696f31b956594b97c0cced0

In Short The Error is CIFS VFS: cifs_mount failed w/return code = -112

Sorry for Not Posting Whole Log but they contains some Personal Information.i guess they are not necessary.

needs-repro providehyperv

Most helpful comment

Not working. I must use hyper V with vagrant because I don't have admin rights on my machine, I can only elevate rights and use admin prompt. So VirtualBox cannot be used. Therefore I use hyper V and shared folder do not work. My experience is that vagrant is not mature because we have to configure it endlessly with tiresome workarounds for everything.

All 9 comments

I just tried this and it is working OK for me with on Windows 10 "1709" with Vagrant 2.0.1

Use this sequence of powershell commands to run:

PS> $env:VAGRANT_SMB_USERNAME = "user@DOMAIN"
PS> $env:VAGRANT_SMB_PASSWORD = "PASSWORD"
PS> vagrant up; vagrant reload
PS C:\Users\tapuzzo\Documents\Vagrant> cd .\CentOS6\
PS C:\Users\tapuzzo\Documents\Vagrant\CentOS6> vagrant up; vagrant reload
Bringing machine 'default' up with 'hyperv' provider...
==> default: Verifying Hyper-V is enabled...
==> default: Configured differencing disk instead of cloning
==> default: Importing a Hyper-V instance
    default: Please choose a switch to attach to your Hyper-V instance.
    default: If none of these are appropriate, please open the Hyper-V manager
    default: to create a new virtual switch.
    default:
    default: 1) ExternalSwitch
    default: 2) Default Switch
    default: 3) DockerNAT
    default:
    default: What switch would you like to use? 2

. . . logs of cifs-utils getting installed . . .

==> default: Machine 'default' has a post `vagrant up` message. This is a message                       
==> default: from the creator of the Vagrantfile, and not from Vagrant itself:                          
==> default:                                                                                            
==> default: VM is initialized but not ready.  Please run `vagrant reload` to finalize.                 
==> default: Attempting graceful shutdown of VM...                                                      
==> default: Starting the machine...                                                                    
==> default: Waiting for the machine to report its IP address...                                        
    default: Timeout: 120 seconds                                                                       
    default: IP: 172.24.142.6                                                                           
==> default: Waiting for machine to boot. This may take a few minutes...                                
    default: SSH address: 172.24.142.6:22                                                               
    default: SSH username: vagrant                                                                      
    default: SSH auth method: private key                                                               
==> default: Machine booted and ready!                                                                  
==> default: Preparing SMB shared folders...                                                            
==> default: Mounting SMB shared folders...                                                             
    default: C:/Users/tapuzzo/Documents/Vagrant/CentOS6 => /vagrant                                     
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`              
==> default: flag to force provisioning. Provisioners marked to run always will still run.              

==> default: Machine 'default' has a post `vagrant up` message. This is a message                       
==> default: from the creator of the Vagrantfile, and not from Vagrant itself:                          
==> default:                                                                                            
==> default: Your VM is ready for use.                                                                  

PS> vagrant ssh -c "ls -l /vagrant"
total 4
-rwxr-xr-x. 0 vagrant vagrant 760 Dec  6 21:54 Vagrantfile
Connection to 172.24.142.5 closed.

Vagrantfile:

Vagrant.configure("2") do |config|
  config.vm.box = "centos/6"
  config.vm.provider "hyperv" do |h|
    h.differencing_disk = true # Faster cloning and uses less disk space
  end
  unless File.exist?(".vagrant/machines/default/hyperv/action_provision")
    config.vm.provision "shell", inline: <<-SHELL
      yum install -y cifs-utils </dev/null
    SHELL
    config.vm.post_up_message = "VM is initialized but not ready.  Please run `vagrant reload` to finalize."
  else
    config.vm.synced_folder '.', '/vagrant', {
      type: 'smb', mount_options: ['vers=3.0'],
      smb_username: ENV['VAGRANT_SMB_USERNAME'],
      smb_password: ENV['VAGRANT_SMB_PASSWORD']
    }
    config.vm.post_up_message = "Your VM is ready for use."
  end
end

I tried with both an External Switch manually configured and with the Default Switch provided by Windows 10 1709 and both are working with the Vagrant file shown above.

I am loading ubuntu 16.04 server. For me the first vagrant up worked, but subsequent ones failed after a reboot of the host system. The symptoms are identical to those described above. I am using hyper v on Windows 10 with Fall creators update.

Not working. I must use hyper V with vagrant because I don't have admin rights on my machine, I can only elevate rights and use admin prompt. So VirtualBox cannot be used. Therefore I use hyper V and shared folder do not work. My experience is that vagrant is not mature because we have to configure it endlessly with tiresome workarounds for everything.

Synced folder via SMB/CIFS and HyperV on Windows 10 Pro x64 work for me.
This is what I am currently using (originally from a roots.io Trellis Vagrantfile):
config.vm.synced_folder './src', '/dest-on-remote', owner: 'vagrant', group: 'www-data', mount_options: ["vers=3.02","mfsymlinks","dir_mode=0776","file_mode=0775","sec=ntlm"], type: "smb"

However, when a certain amount of synced folders are mounted, subsequent mounts will fail:
mount error(5): Input/output error

$ vagrant ssh $ dmesg
Status code returned 0xc00000d0 STATUS_REQUEST_NOT_ACCEPTED CIFS VFS: Send error in SessSetup = -5 [ CIFS VFS: cifs_mount failed w/return code = -5

I already tried using a different vers (1.0; 2.0; and so on) but this changed nothing (except a different error when a non-available version was tried) and a different sec like ntlmssp, but without success.

I don't have admin rights on my machine

"Vagrant requires administrator access to create SMB shares and
may request access to complete setup of configured shares."

when a certain amount of synced folders are mounted, subsequent mounts will fail

This is the behaviour I was seeing with the Hyper-V "Default Switch".
I manually created a new External switch and used that, which appears to have fixed the problem.

run powershell as administrator and do vagrant up

Hi there,

It looks like this has been resolved within a previously shipped version of Vagrant so I am now closing this issue. If the original issue was not fully resolved, please reopen this issue or create a new one.

Cheers!

I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DreadPirateShawn picture DreadPirateShawn  ยท  3Comments

dorinlazar picture dorinlazar  ยท  3Comments

StefanScherer picture StefanScherer  ยท  3Comments

luispabon picture luispabon  ยท  3Comments

jazzfog picture jazzfog  ยท  3Comments