Problem
I'm struggling to have vagrant mounting shared folders via SMB.
Environment
Windows 10 Pro with Hyper-V and SMB features enabled
Vagrant 2.2.6 with vagrant-vbguest (0.21.0, global) plugin
Homestead.yaml file
ip: "192.168.10.10"
memory: 2048
cpus: 2
provider: hyperv
authorize: c:/Users/sgrat/.ssh/id_rsa.pub
keys:
- c:/Users/sgrat/.ssh/id_rsa
folders:
- map: Sites/mysite
to: /home/vagrant/mysite
php: '7.3'
type: "smb"
smb_host: 127.0.0.1
smb_username: vagrant
smb_password: vagrant
sites:
- map: mysite.test
to: /home/vagrant/mysite
databases:
- mysitedb
features:
- mariadb: true
- ohmyzsh: false
- webdriver: false
Error
Vagrant requires administrator access to create SMB shares and
may request access to complete setup of configured shares.
==> homestead: Setting hostname...
==> homestead: Mounting SMB shared folders...
homestead: C:/Users/sgrat/Desktop/Sites/Homestead => /vagrant
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-4a666e6cffbb30e1d0bc7bb643cb3aee-6ad5fdbcbf2eaa93bd62f92333a2e6e5,uid=1000,gid=1000 //192.168.1.14/vgt-4a666e6cffbb30e1d0bc7bb643cb3aee-6ad5fdbcbf2eaa93bd62f92333a2e6e5 /vagrant
The error output from the last command was:
mount error(13): Permission denied
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
Additional attempts
I also installed vboxsf fs on guest machine after vagrant ssh with sudo apt-get install virtualbox-guest-x11 and even checked for last cifs-utils version.
I even created a local/admin user with name/password vagrant and granted all privilages on both "Sites" folder and "Sites" shared folder.
Update #1
Shared "Sites" folder on Windows host, so updated homestead shared folder path to start from that instead from C: drive.
Is it correct?
Related
I'm used to working in a windows environment and have homestead up and running on my windows machine.
I'm now trying to set up homestead on a machine running ubuntu, partly as a development opportunity for me and to overcome some perceived issues in windows that I've experienced with setting up development workflow. anyway....
I've successfully installed homestead and after vagrant upand changing my hosts file I can get the vagrant machine up and running. I can ping the url for my development site. However when I try and view the site in the browser - i get a timeout.
I can SSH into the vagrant machine but navigating to home/vagrantthere is no code folder - so it doesn't appear to be creating that folder on set up.
I added that folder from within the machine as sudo and gave write permissions - On examining the start up script I can see this message:
homestead: /home/vagrant/code => /media/ray/Develop/vagrant/projects
==> homestead: Detected mount owner ID within mount options. (uid: 1000 guestpath: /home/vagrant/code)
==> homestead: Detected mount group ID within mount options. (gid: 1000 guestpath: /home/vagrant/code)
Q1: Is there an error log within homestead I can view to try and work out what the issues are?
Q2: For now I'm assuming it may be a mapping issue in my homestead.yaml file - although in the past on windows this has manifested itself as ǹo input file detected`error.
My code is on a separate partition to the ubuntu machine (on my dual boot laptop). I can navigate to the files which are located in the media folder with this path:
/media/ray/Develop/vagrant/projects
Here is my current homestead.yamlfile:
---
ip: "192.168.56.56"
memory: 2048
cpus: 2
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: /media/ray/Develop/vagrant/projects
to: /home/vagrant/code
sites:
- map: wedleague.loc
to: /home/vagrant/code/wedleague/public
php: "8.1"
databases:
- homestead
- wedleague
- sandpit
features:
- mysql: true
- mariadb: false
- postgresql: false
- ohmyzsh: false
- webdriver: true
services:
- enabled:
- "mysql"
# - disabled:
# - "postgresql#11-main"
ports:
- send: 33060 # MySQL/MariaDB
to: 3306
Have I mapped this correctly? - I'm still getting used to ubuntu file system (mounted/symlink etc) over windows so wonder if I've made an error here.
Thank you
After running vagrant up I get the following error message.
Vagrant requires administrator access to create SMB shares and
may request access to complete setup of configured shares.
==> homestead: Setting hostname...
==> homestead: Mounting SMB shared folders...
homestead: C:/Code => /home/*****/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 cifs -o vers=3.02,credentials=/etc/smb_creds_vgt-07cc5c30ef2cc20d12e837c88c36370a-66f0bd5cbca4d218f5f0b8a5f1712727,uid=1000,gid=1000,mfsymlinks,_netdev,nofail //169.254.x.x/vgt-07cc5c30ef2cc20d12e837c88c36370a-66f0bd5cbca4d218f5f0b8a5f1712727 /home/*****/code
The error output from the last command was:
mount error(2): No such file or directory
I am able to ssh into the HyperV instance and when I run the command it returns the same. If I look at the properties of C:/Code folder I can see the network path is \\PCNAME\vgt-07cc5c30ef2cc20d12e837c88c36370a-66f0bd5cbca4d218f5f0b8a5f1712727 so the same as the mount command other than the PCNAME is now an IP. I can ping the IP from within the instance and seems to work ok.
Homestead file:
folders:
- map: C:/Code
to: /home/vagrant/code
type: smb
smb_username: vagrant
smb_password: vagrant
The vagrant user has full permissions to the local code folder.
I am running Windows 11, Vagrant 2.3.1, HyperV 10. The External Switch is set-up via my Wi-Fi - could that cause an issue?
Environment
Windows 10 pro with Hyper-V
Vagrant v.2.2.6
Status
Trying to starting homestead VM with SMB shared folders via Powershell and admin user, but with no luck.
Shared 'Site' folder and created a dedicated user (usr:vagrant, pwd:vagrant) with full access to shared folder.
Really struggling on this.
Set shared folder as Sites\mysite (without complete path) since i'm sharing just this specific folder, is it right?
Error
PS C:\Users\sgrat\Desktop\Sites\Homestead> vagrant up --provision
Bringing machine 'homestead' up with 'hyperv' provider...
==> homestead: Verifying Hyper-V is enabled...
==> homestead: Verifying Hyper-V is accessible...
homestead: Configuring the VM...
==> homestead: Starting the machine...
An error occurred while executing a PowerShell script. This error
is shown below. Please read the error message and see if this is
a configuration error with your system. If it is not, then please
report a bug.
Script: start_vm.ps1
Error:
Failed to start VM 'homestead' failed to start.
Synthetic SCSI Controller (Instance ID 480D9BCD-B214-461F-976E-2A9A546F9BB8): Failed to Power on with Error 'General access denied error'.
Account does not have permission to open attachment 'C:\Users\sgrat\Desktop\Sites\Homestead\.vagrant\machines\homestead\hyperv\Virtual Hard Disks\ubuntu-18.04-amd64.vhdx'. Error: 'General access denied error'.
'homestead' failed to start. (Virtual machine ID 555B1C43-AC2B-4B9C-A9B2-94BF40753C40)
'homestead' Synthetic SCSI Controller (Instance ID 480D9BCD-B214-461F-976E-2A9A546F9BB8): Failed to Power on with Error 'General access denied error' (0x80070005). (Virtual machine ID 555B1C43-AC2B-4B9C-A9B2-94BF40753C40)
'homestead': Account does not have permission to open attachment 'C:\Users\sgrat\Desktop\Sites\Homestead\.vagrant\machines\homestead\hyperv\Virtual Hard Disks\ubuntu-18.04-amd64.vhdx'. Error: 'General access denied error' (0x80070005). (Virtual machine ID 555B1C43-AC2B-4B9C-A9B2-94BF40753C40)
Homestead.yaml
ip: "192.168.10.10"
memory: 2048
cpus: 2
provider: hyperv
authorize: c:/Users/sgrat/.ssh/id_rsa.pub
keys:
- c:/Users/sgrat/.ssh/id_rsa
folders:
- map: Sites\mysite
to: /home/vagrant/mysite
php: '7.2'
type: "smb"
smb_host: 127.0.0.1
smb_username: vagrant
smb_password: vagrant
sites:
- map: mysite.test
to: /home/vagrant/mysite
databases:
- mysitedb
features:
- mariadb: true
- ohmyzsh: false
- webdriver: false
I cannot speak to the validity of using relative file paths, I just remember I had some issues when I did not use complete. I am using Git Bash, but other than that same setup as you: Win 10, Hyper-V, Vagrant 2.2.6.
Here is my Homestead.yaml file:
---
ip: "192.168.10.10"
memory: 2048
cpus: 2
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: C:\Users\leif.lundberg\code
to: /home/vagrant/code
type: "nfs"
sites:
- map: homestead.test
to: /home/vagrant/code/symfobase/public
databases:
- homestead
features:
- mariadb: false
Also, I do not know if your keys mapping is correct and may cause an issue using forwardslash "/" instead of backslash "\".
I have followed instructions (https://laravel.com/docs/5.2/homestead) to set up laravel running in a Vagrant/Homestead box.
In the end, I should be able to the website from virtual machine by accessing homestead.app in browser on my host machine.
I´ve tried accessing in different ways, with and without specifying port 8000:
http://homestead.app - connection timeout
http://192.168.10.10 - connection timeout
http://localhost - connection timeout
http://127.0.0.1 - connection refused
After troubleshooting I have found that files are not synced to the virtual machine.
E:\homestead_local\Laravel\public\ contains index.php which I try to access. It is not synced to the VM.
I can´t find any error logs on server.
Also, on VM home/vagrant folder was empty after I did everything from instructions. I´m not sure if that was supposed to happen.
Instructions of what I did, keeping them short:
Installed Virtualbox 4.2 and Vagrant 1.8.1
Dowloaded vagrant box:
vagrant box add laravel/homestead
Installed Homestead 0.4.1
git clone https://github.com/laravel/homestead.git Homestead
Initialized homestead:
bash init.sh
Edited homestead.yaml file
Edited hosts file
Hosts file:
192.168.10.10 homestead.app
127.0.0.1 homestead.app
homestead.yaml file:
ip: "192.168.10.10"
memory: 768
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: E:\HSprojects
to: /home/vagrant/Code
sites:
- map: homestead.app
to: /home/vagrant/Code/Laravel/public
databases:
- homestead
Questions
After running "vagrant up" my CMD shows this:
....
default: Mounting shared folders...
default: /vagrant => E:/Homestead
Why is it showing E:/Homestead and not E:/HSProjects?
Is sharing between folders bidirectional? I can't find a clear answer on this, but I assume they are.
Previously, I manually setup my own VM on VirtualBox and configured it so it would also work when I'm coding offline (no internet/not connected to a router). I did this using settings in the VirtualBox GUI and also in Apache on the VM.
Now I'm interested in learning nginx and I've decided to try and use Laravel's Homestead. The tutorials I'm looking at seem to have the assumption I will be accessing the Homestead VM across the network (even though of course it's on the same PC). What do I need to do to ensure the VM will be accessible when I'm offline (like when I'm coding on a plane or train)? I'd like to still be able to have access to the internet from the VM whenever I do get back on WiFi (ie. for apt-get, etc.).
(note: My host machine is running Windows 7 64-bit)
Download and install fresh copies of Vagrant and Virtualbox.
https://dl.bintray.com/mitchellh/vagrant/vagrant_1.7.2.msi
http://dlc-cdn.sun.com/virtualbox/4.3.22/VirtualBox-4.3.22-98236-Win.exe
Also download laravel/homestead manually
https://vagrantcloud.com/laravel/boxes/homestead/versions/0.2.2/providers/virtualbox.box
to my downloads folder C:\Downloads\homestead-0-2-2.box
After Installing Virtualbox and Vagrant. Installed laravel/homestead by running the following command in git bash (you can download git bash here: http://git-scm.com/downloads).
vagrant box add laravel/homestead /c/downloads/homestead-0-2-2.box
Run this command inside C:\users\yourusername
git clone https://github.com/laravel/homestead.git Homestead
NB: This will create this folder: C:\Users\yourusername\Homestead
With some files.
Still in Git bash, cd into C:\Users\yourusername\Homestead and run this command:
bash init.sh
NB: this will create a folder C:\Users\yourusername\.homestead that contains Homestead.yaml and some other files
Then Generate an SSH key which you will need when you want to login to your VM by running this command:
ssh-keygen -t rsa -C "youremailaddress#youremail.com"
NB: This will ask some question simply hit enter or type yes and hit enter.
This will create your ssh key inside C:\Users\yourusername\.ssh
Then you need to configure homestead by editing for Nginx
C:\Users\digitlimit\Homestead\Homestead.yaml
You can right-click Homestead.yaml file then click open then choose to open with wordpad.
My Homestead.yaml looks this after editing:
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: /wamp/www
to: /home/vagrant/Code
sites:
- map: laravel.dev
to: /home/vagrant/Code/laravel/public
databases:
- homestead
variables:
- key: APP_ENV
value: local
# blackfire:
# - id: foo
# token: bar
NB: To understand the mapping which is a process of sharing a folder between the host and the VM:
My laravel project is located at C:\wamp\www\laravel
This directory /home/vagrant/Code will be inside the VM after installation.
So what am telling VM is, whenever you see /home/vagrant/Code reference this folder C:\wamp\www\laravel
Also in this:
sites:
- map: laravel.dev
to: /home/vagrant/Code/laravel/public
What we are saying here is when i go to my browser and type http://laravel.dev display the content of /home/vagrant/Code/laravel/public which is actually pointing to C:\www\wamp\laravel\public
After editing Homestead.yaml file save your chnages
NB: Before we can use http://laravel.dev in the host web browser to view our laravel project, we need to add this the following to the hosts file located in
C:\Windows\System32\drivers\etc\hosts
Add this ip address under the list of other ip address listed if any:
192.168.10.10 laravel.dev
Finally, go back to your Git bash, ensure you are in
/c/Users/yourusername/homestead and type:
vagrant up
Wait for vagrant to complete its processes. Click yes when you see any dialog box asking for permission to create network adapter on your system
Any VM running on your development machine will be accessible when you're offline. Just make sure you setup your development machine's host file to have the VM's location set.
If you're following the Laravel Homestead Setup:
In scripts/homestead.rb, you'll have a line that has the IP Address of the VM.
# in scripts/homestead.rb
# Configure A Private Network IP
config.vm.network :private_network, ip: settings["ip"] ||= "192.168.10.10"
Add this IP address into to your hosts file. This is located usually in C:\Windows\System32\drivers\etc\hosts
#in hosts file
192.168.10.10 yourwebsite.dev