Vagrant sync folder doesn't work on windows 10 - vagrant

I'm trying to sync folders from a windows 10 hosto to a ubuntu guest but I get this error:
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'ubuntu/trusty64' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 8080 (guest) => 8080 (host) (adapter 1)
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
default: The guest additions on this VM do not match the installed version of
default: VirtualBox! In most cases this is fine, but in rare cases it can
default: prevent things such as shared folders from working properly. If you see
default: shared folder errors, please make sure the guest additions within the
default: virtual machine match the version of VirtualBox you have installed on
default: your host and reload your VM.
default:
default: Guest Additions Version: 4.3.36
default: VirtualBox Version: 5.0
==> default: Mounting shared folders...
default: /vagrant => C:/sync_workspace
default: /sync_workspace => C:/sync_workspace
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 vboxsf -o uid=`id -u vagrant`,gid=`getent group vagrant | cut -d: -f3`,nolock,vers=3 core /sync_workspace
mount -t vboxsf -o uid=`id -u vagrant`,gid=`id -g vagrant`,nolock,vers=3 core /sync_workspace
The error output from the last command was:
stdin: is not a tty
unknown mount option `nolock'
valid options:
rw mount read write (default)
ro mount read only
uid =<arg> default file owner user id
gid =<arg> default file owner group id
ttl =<arg> time to live for dentry
iocharset =<arg> i/o charset (default utf8)
convertcp =<arg> convert share name from given charset to utf8
dmode =<arg> mode of all directories
fmode =<arg> mode of all regular files
umask =<arg> umask of directories and regular files
dmask =<arg> umask of directories
fmask =<arg> umask of regular files
Here is my Vagrantfile
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.network "forwarded_port", guest: 8080, host: 8080
config.vm.synced_folder "C:/Users/rafa/Documents/personal docs", "/vagrant_data/sync_workspace"
end
Host : Windows 10
Guest: Ubuntu
Vagrant: 1.8.1
VirtualBox : Version 5.0.20 r106931
Any Help?

Install the vagrant vaguest plugin and let it install the host's VirtualBox Guest Additions on the guest system and in your case it will update your guest addition

Also try apt-get update in your guest OS.

Related

how to solve this SMB share folder when vagrant sync folder fail in this case?

I have a vagrant in my Win10 PC.
Vagrant.configure("2") do |config|
config.vm.box = "generic/centos7"
config.vm.synced_folder "D:/Users/88888888/vagrant_proj/vagrant_data", "/vagrant_data"
config.vm.network "private_network", ip: "172.22.244.28"
end
When I vagrant up my vm, I get below error when sync folder:
MINGW64 ~/vagrant_proj/vagrant_vm/vmware_desktop_centos7
$ vagrant up
Bringing machine 'default' up with 'hyperv' provider...
==> default: Verifying Hyper-V is enabled...
==> default: Verifying Hyper-V is accessible...
default: Configuring the VM...
default: Setting VM Enhanced session transport type to disabled/default (VMBus)
Vagrant requires administrator access for pruning SMB shares and
may request access to complete removal of stale shares.
==> default: Starting the machine...
==> default: Waiting for the machine to report its IP address...
default: Timeout: 120 seconds
default: IP: 172.22.244.28
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 172.22.244.28:22
default: SSH username: vagrant
default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Preparing SMB shared folders...
default: You will be asked for the username and password to use for the SMB
default: folders shortly. Please use the proper username/password of your
default: account.
default:
default: Username (user[#domain]): ABC\88888888
default: Password (will be hidden):
Error! Your console doesn't support hiding input. We'll ask for
input again below, but we WILL NOT be able to hide input. If this
is a problem for you, ctrl-C to exit and fix your stdin.
default: Password (will be hidden): Aircraft04!
Vagrant requires administrator access to create SMB shares and
may request access to complete setup of configured shares.
==> default: Mounting SMB shared folders...
default: D:/Users/88888888/vagrant_proj/vagrant_data => /vagrant_data
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 vers=2.0,credentials=/etc/smb_creds_vgt-2d3036366c24d0c86eee3d4f63f20f4f-adda498f781708cde2d8e46c475e9593,uid=1000,gid=1000,mfsymlinks,_netdev,nofail //10.0.129.112/vgt-2d3036366c24d0c86eee3d4f63f20f4f-adda498f781708cde2d8e46c475e9593 /vagrant_data
The error output from the last command was:
mount error(5): Input/output error
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
how to solve this SMB share folder?
the version is below:
$ vagrant.exe --version
Vagrant 2.2.19
and I use the vagrant HyperV provider.

Vagrant Error: symlink has no referent

I'm struggling with old bug/error, I'm listed a lot of possible solutions, but with no result for me.
I have a Virtual Box and Vagrantfile:
Vagrant.configure("2") do |config|
config.vm.box = "debian/jessie64"
config.vm.network "private_network", ip: "192.168.56.101"
config.vm.synced_folder "../mysite.local", "/code/mysite.local", type: "virtualbox"
config.vm.provider "virtualbox" do |vb|
vb.memory = "2048"
end
end
It was ok until I created the symlinked folder. So when I type vagrant up it throws an error:
==> default: Checking if box 'debian/jessie64' is up to date...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
==> default: Machine booted and ready!
[default] GuestAdditions 5.1.31 running --- OK.
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...
==> default: Rsyncing folder: /Users/user/code/sandbox/mysite.local/ => /vagrant
There was an error when attempting to rsync a synced folder.
Please inspect the error message below for more info.
Host path: /Users/user/code/sandbox/mysite.local/
Guest path: /vagrant
Command: "rsync" "--verbose" "--archive" "--delete" "-z" "--copy-links" "--no-owner" "--no-group" "--rsync-path" "sudo rsync" "-e" "ssh -p 2222 -o LogLevel=FATAL -o ControlMaster=auto -o ControlPath=/var/folders/kh/sp8l6c0d1s3_jqkv6cv2jzlw0000gn/T/ssh.832 -o ControlPersist=10m -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i '/Users/user/code/sandbox/mysite.local/.vagrant/machines/default/virtualbox/private_key'" "--exclude" ".vagrant/" "/Users/user/code/sandbox/mysite.local/" "vagrant#127.0.0.1:/vagrant"
Error: symlink has no referent:
"/Users/user/code/sandbox/mysite.local/web"
rsync error: some files could not be transferred (code 23) at
/BuildRoot/Library/Caches/com.apple.xbs/Sources/rsync/rsync-
52/rsync/main.c(996) [sender=2.6.9]
What I need to do to fix that issue?
So, deleting broken link is not the best solution for that question. By default - "home" synchronized directory is /vagrant. And I've made another synced folder. It was the conflict between them.
config.vm.synced_folder ".", "/vagrant", disabled: true
After adding these lines to my Vagrantfile the error is gone.
You have a broken symlink /Users/user/code/sandbox/mysite.local/web, hence rsync cannnot copy it to your VM. Either fix your symlink or move it away before you run vagrant up:
cd /Users/user/code/sandbox/mysite.local
mv web ../

Vagrant can't assign static ip to box

I have the following inside my Vagrant file.
config.vm.network "private_network", ip: "192.168.33.12"
When I "vagrant up", vagrant is assigning 127.0.0.1. I'm not sure what's causing this. Below is the full trace.
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set forwarded ports...
==> default: Fixed port collision for 22 => 2222. Now on port 2200.
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
==> default: Forwarding ports...
default: 22 (guest) => 2200 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2200
default: SSH username: vagrant
default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
default: /vagrant => C:/vm2
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.
what you see here
default: SSH address: 127.0.0.1:2200
is not your VM IP address - this is just for vagrant to ssh into the box using an available port (in your case 2200). vagrant configures on your VM the eth0 interface to communicate with the host
Login to the VM and run ifconfig you will see you have (at least) 2 interfaces available with eth0 on 10.0.2.15 and eth1 on 192.168.33.12
As a shorthand way of doing this, a oneliner you can run from the host to see assigned IPs on the guest:
$ vagrant ssh -c "ifconfig | grep 'inet addr'"
Which will give you an output like this:
inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0
inet addr:192.168.200.200 Bcast:192.168.200.255 Mask:255.255.255.0
inet addr:127.0.0.1 Mask:255.0.0.0
Here are the steps that i choose while setting up the static ip of the Ubuntu machine:
ls /etc/netplan/ //go to this directory to find the config file
Note: the YAML file is very strict about the indentations e.g
dhcp4:true //will give wrong indentation error
dhcp4: true //right way to give
Now edit the config file:-
sudo nano /etc/netplan/01-netcfg.yaml
Change Default settings from :-
network:
version: 2
renderer: networkd
eth0:
dhcp4: true
dhcp6: false
optional: true
nameservers:
addresses: [8.8.8.8,8.8.4.4]
To
network:
version: 2
renderer: networkd
ethernets:
eth0:
dhcp4: no
addresses: [172.28.32.11/16] //here choose your desired IP
gateway4: 172.28.32.1 //provide the gateway address,
nameservers:
addresses: [8.8.8.8,8.8.4.4]
Now do :
sudo netplan apply // to apply the network settings
You can then check that the ip address remains same during any course between vagrant halt/up
Here is what i did for the virtual box set machine of vagrant:
Add this to to vagrant file :-
config.vm.network "private_network", ip: "any IP address that you choose"
Then do the Vagrant Reload and you should be good.
In case the VM stucks for Vagrant Up command in retrying the connect or ssh .. do this:-
Run the below command from the cmder console:-
vagrant plugin install vagrant-vbguest
After this enable Vagrant GUI by adding the following to the vagrant file:-
config.vm.provider :virtualbox do |vb|
vb.gui = true
end
Now do the vagrant up
the vagrant gui window will open and Keep Pressing "S" to skip and enter the login screen
Login with the username/password which is root/vagrant by default
and run the following command:-
sudo ln -s /opt/VBoxGuestAdditions-4.3.10/lib/VBoxGuestAdditions /usr/lib/VBoxGuestAdditions
Now come out of the vagrant gui window shell and
remove the line added earlier for enabling the vagrant gui
from the cmder console do "vagrant up" again
Done!

Vagrant Laravel Homestead - error when running vagrant up

I have followed the tutorial on https://laravel.com/docs/5.0/homestead and when running the step 'vagrant up', I get the following error message (below)
Any ideas what the problem is? Running latest version of Oracle VirtualBox and the latest version of Vagrant. Regards
--
C:\Users\Anders\Vagrant\Homestead>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'laravel/homestead'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'laravel/homestead' is up to date...
==> default: Setting the name of the VM: homestead-7
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
==> default: Forwarding ports...
default: 80 (guest) => 8000 (host) (adapter 1)
default: 443 (guest) => 44300 (host) (adapter 1)
default: 3306 (guest) => 33060 (host) (adapter 1)
default: 5432 (guest) => 54320 (host) (adapter 1)
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
default:
default: Vagrant insecure key detected. Vagrant will automatically replace
default: this with a newly generated keypair for better security.
default:
default: Inserting generated public key within guest...
default: Removing insecure key from the guest if it's present...
default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
GuestAdditions versions on your host (5.0.16) and guest (5.0.12) do not match.
Reading package lists...
Building dependency tree...
Reading state information...
dkms is already the newest version.
linux-headers-3.19.0-25-generic is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
Copy iso file C:\Program Files\Oracle\VirtualBox\VBoxGuestAdditions.iso into the
box /tmp/VBoxGuestAdditions.iso
mount: block device /tmp/VBoxGuestAdditions.iso is write-protected, mounting rea
d-only
Installing Virtualbox Guest Additions 5.0.16 - guest version is 5.0.12
Verifying archive integrity... All good.
Uncompressing VirtualBox 5.0.16 Guest Additions for Linux............
VirtualBox Guest Additions installer
Removing installed version 5.0.12 of VirtualBox Guest Additions...
Stopping VirtualBox Additions ...fail!
(Cannot unload module vboxguest)
Removing existing VirtualBox DKMS kernel modules ...done.
Removing existing VirtualBox non-DKMS kernel modules ...done.
Stopping VirtualBox Guest Addition service ...done.
Copying additional installer modules ...
Installing additional modules ...
Removing existing VirtualBox DKMS kernel modules ...done.
Removing existing VirtualBox non-DKMS kernel modules ...done.
Building the VirtualBox Guest Additions kernel modules ...done.
Doing non-kernel setup of the Guest Additions ...done.
You should restart your guest to make sure the new modules are actually used
Installing the Window System drivers
Could not find the X.Org or XFree86 Window System, skipping.
An error occurred during installation of VirtualBox Guest Additions 5.0.16. Some
functionality may not work as intended.
In most cases it is OK that the "Window System drivers" installation failed.
==> default: Checking for guest additions in VM...
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
default: /vagrant => C:/Users/Anders/Vagrant/Homestead
default: /home/vagrant/Code => C:/Users/Anders/Code
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 vboxsf -o uid=`id -u vagrant`,gid=`getent group vagrant | cut -d: -f3`,
actimeo=1 home_vagrant_Code /home/vagrant/Code
mount -t vboxsf -o uid=`id -u vagrant`,gid=`id -g vagrant`,actimeo=1 home_vagran
t_Code /home/vagrant/Code
The error output from the last command was:
unknown mount option `actimeo=1'
valid options:
rw mount read write (default)
ro mount read only
uid =<arg> default file owner user id
gid =<arg> default file owner group id
ttl =<arg> time to live for dentry
iocharset =<arg> i/o charset (default utf8)
convertcp =<arg> convert share name from given charset to utf8
dmode =<arg> mode of all directories
fmode =<arg> mode of all regular files
umask =<arg> umask of directories and regular files
dmask =<arg> umask of directories
fmask =<arg> umask of regular files
C:\Users\Anders\Vagrant\Homestead>
--
vagrant file:
--
require 'json'
require 'yaml'
VAGRANTFILE_API_VERSION = "2"
confDir = $confDir ||= File.expand_path("~/.homestead")
homesteadYamlPath = confDir + "/Homestead.yaml"
homesteadJsonPath = confDir + "/Homestead.json"
afterScriptPath = confDir + "/after.sh"
aliasesPath = confDir + "/aliases"
require File.expand_path(File.dirname(__FILE__) + '/scripts/homestead.rb')
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
if File.exists? aliasesPath then
config.vm.provision "file", source: aliasesPath, destination: "~/.bash_aliases"
end
if File.exists? homesteadYamlPath then
Homestead.configure(config, YAML::load(File.read(homesteadYamlPath)))
elsif File.exists? homesteadJsonPath then
Homestead.configure(config, JSON.parse(File.read(homesteadJsonPath)))
end
if File.exists? afterScriptPath then
config.vm.provision "shell", path: afterScriptPath
end
end
--
yaml file:
--
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/Vagrant/Homestead/homestead.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: ~/Code
to: /home/vagrant/Code
type: "nfs"
sites:
- map: homestead.app
to: /home/vagrant/Code/Laravel/public
hhvm: true
databases:
- homestead
The issue you're experiencing with Homestead has been documented in Github. There is a workaround provided, which is as follows:
Solution: Remove type: "nfs" on your folders of Homestead.yaml.
http://docs.vagrantup.com/v2/synced-folders/nfs.html
"Windows users: NFS folders do not work on Windows hosts. Vagrant will
ignore your request for NFS synced folders on Windows.
Original Answer (for the question before it was edited)
Now the issue seems to be with your ssh key, or lackthereof.
No such file or directory # rb_sysopen - C:/Users/Anders/.ssh/id_rsa (Errno::ENOENT)
The section in the guide you linked titled Set Your SSH Key has the following instructions to help you generate one (trimmed to the relevant Windows instructions):
Set Your SSH Key
[...]
On Windows, you may install Git and use the Git Bash shell included with Git to issue the command above. Alternatively, you may use PuTTY and PuTTYgen.
Once you have created a SSH key, specify the key's path in the authorize property of your Homestead.yaml file.
If you are not that comfortable with commandlines, I would recommend using the PuTTYgen method.
This is a problem with your Homestead.yaml file in ~/.homestead directory. I need see the file content to help you more.
After you had fixed the indention style to use only space characters, the another problem happenned because you not generate a pair (public and private) of keys yet. To do that:
mkdir -p ~/.ssh && cd ~/.ssh
ssh-keygen -b 2048 -t rsa -C "you#domain.com"
You can let the default file name (id_rsa), type the password and repeat the same password.
In case anyone else ends up here via Google and didn't read all the comments too well (like I did).
I ran into the same issue of not being able to vagrant up with the following error:
Vagrant was unable to mount VirtualBox shared folders. This is usually
because the filesystem "vboxsf" is not available. This filesystem is
made available via the VirtualBox Guest Additions and kernel module.
Please verify that these guest additions are properly installed in the
guest. This is not a bug in Vagrant and is usually caused by a faulty
Vagrant box. For context, the command attempted was:
mount -t vboxsf -o actimeo=1,nolock,uid=1000,gid=1000 var_www_dev.mybox /var/www/dev.mybox
The error output from the command was:
fmask =<arg> umask of regular files
As Lucas mentioned here Windows users can install the vagrant-winnfsd plugin which allows you to use NFS shared folders in Vagrant and Homestead).
So I solved this error by running vagrant plugin install vagrant-winnfsd followed by a vagrant up.

vboxsf error when passing owner,group and mount options parameters

Vagrant Version 1.6.3
Virtual Box 4.3.12
VBoxGuestAdditions-4.3.2
Host OS -> Windows 8
Guest OS -> CentOS 6.5
Vagrant synced_folder works fine when this is the content of Vagrentfile
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.synced_folder ".", "/var/www"
But I am unable to change the permissions of files or directories in synced_folder (/var/www).
https://github.com/mitchellh/vagrant/issues/897
To solve this problem I made following changes in Vagrentfile
https://serverfault.com/questions/398414/vagrant-set-default-share-permissions
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.synced_folder ".", "/var/www",
:owner=> 'shiva',
:group=> 'shiva',
:mount_options=> ['dmode=>777', 'fmode=>666']
(where 'shiva' is the user which I created, I deleted the default user 'vagrant')
Now the problem is when I try to do vagrant up ,it shows this error
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 22 => 2222 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: shiva
default: SSH auth method: password
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Remote connection disconnect. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
default: /var/www => C:/Users/Shiva/CentOSDevEnv_v1_1
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 vboxsf -o uid=`id -u shiva`,gid=`getent group shiva | cut -d: -
f3`,dmode=>777,fmode=>666 var_www /var/www
mount -t vboxsf -o uid=`id -u shiva`,gid=`id -g shiva`,dmode=>777,fmode=
>666 var_www /var/www
I already go through this link
https://github.com/mitchellh/vagrant/issues/3341
I don't know ruby syntax (Vagrantfile syntax).
I am really stuck here, please help.
The error was in my Vagrantfile syntax, my bad :(
This is the correct syntax
:mount_options=> ['dmode=777', 'fmode=666']
But it would be more helpful if vagrant can show the correct error information , something like
"Error in Vagrantfile syntax"
instead of
"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."

Resources