Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Vagrant Homestead to boot using Hyper-V

I was unable to get homestead to boot using the directions provided here https://laravel.com/docs/5.7/homestead using hyper-V. The original issue was that the machine would not boot it would just hang indefinitely. Once I fixed this issue I encountered 2 more before I was able complete the vagrant up command.

I am not 100% sure this is the right place to post this but I have spent about 2 weeks off and on trying to solve this issue and hopefully I can save someone else a little time if they have similar issues. I was able to use homestead using virtual-box but it was extremely inconvenient to not have Hyper-V running on my PC so I uninstalled virtual-box and tried to setup homestead using Hyper-V. For me the VM would not boot at all. When I looked at it in Hyper-V manager it was just hung at startup. This turned out to be that it is setup as generation 1 box with the drive connected as IDE. For me the solution was to create a new generation 2 VM and connect the provided drive using SCSI. I then disabled secure boot and I was able to boot. Then it failed during the provisioning script trying to mount the default vagrant share. I could not figure out how to modify this call so ended up disabling it as for homestead it is not needed as far as I can tell. Then my third issue was not being able to mount any of the user defined shares in the homestead.yaml file. Some googling on this showed that I needed to make this call with no additional paramters which the script did not seem to provide an option to do. I modified the script and whola the vagrant up command completed successfully. Below are the details of the steps I took. If there is a simpler way to get Vagrant Homestead running using Hyper-V I would appreciate the advice.


Issue 1: Will not boot

Description: The issue seems to be that is trying to boot as a Generation 1 using the IDE controller. This does not seem work for my installation of windows 10 Pro.

Resolution:

1. Created a new VM using Generation 2 and attached the existing 
       "ubuntu-18.04-amd64.vhdx" to it using SCSI.

2. Boot this VM and then shutdown. 

3. Turn off secure boot

4. Replace the Virtual machine files in [VagrantInstallFolder]\boxes\laravel-VAGRANTSLASH-homestead\6.4.0\hyperv with the new ones created above.

5. Delete newly created box from HyperV

Issue 2: Will not mount default Vagrant share

Error Message: ==> homestead-7: Machine booted and ready! No valid IDs were given to the NFS synced folder implementation to prune. This is an internal bug with Vagrant and an issue should be filed.

Description: The vagrant up command fails at the attempt to mount the default vagrant share. I found no way to override the parameters for this call so it was always trying to make the call using nfs which is not supported on Windows. If it is possible to override this call settings then that would be the preferable way. But the only way I could figure out to get the provisioning script to continue to execute is to disable this share.

Resolution:

1. Modify the scripts\homestead.rb file and add the code below to the
 Hyper V config settings section "Configure A Few Hyper-V Settings". This
 will disable the default file share but you can still add your own from
 the homestead.yaml file after completion of issue 3.

#Disable the default Vagrant file share
config.vm.synced_folder ".", "/vagrant", disabled: true

Issue 3: User defined shares in the homestead.yaml file still error.

Error Message:

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,credentials=/etc/smb_creds_vgt-96269f65d23acb279735d26264428995-66f0bd5cbca4d218f5f0b8a5f1712727,uid=1000,gid=1000,nolock,udp,noatime //192.168.1.107/vgt-96269f65d23acb279735d26264428995-66f0bd5cbca4d218f5f0b8a5f1712727 /home/vagrant/code

The error output from the last command was:

mount error(22): Invalid argument Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)

Description: The vagrant up command fails at the attempt to mount the user defined shares in the homestead.yaml file. The mount seems to be passing unneeded parameters to the mount command. We need to override the mount call in the scripts\homestead.rb file to use no parameters.

Resolution:

1. In the "Register All Of The Configured Shared Folders" section replace the line below. 

    Replace 
    config.vm.synced_folder folder['map'], folder['to'], type: folder['type'] ||= nil, **options

    With
    config.vm.synced_folder folder['map'], folder['to'], type: "smb"

2. Then run "vagrant up --provider hyperv"
like image 320
user1819473 Avatar asked Nov 16 '22 18:11

user1819473


1 Answers

What Vagrant Plugins are installed (vagrant plugin list)?

I was getting the following error:

No valid IDs were given to the NFS synced folder implementation to prune. This is an internal bug with Vagrant and an issue should be filed.

Previously, I'd been using NFS and had the following plugin installed: https://github.com/winnfsd/vagrant-winnfsd.

Once I removed the plugin via vagrant plugin uninstall vagrant-winnfsd, provisioning worked.

like image 118
Danny Thompson Avatar answered Dec 01 '22 01:12

Danny Thompson