winnfsd / vagrant-winnfsd

Manage and adds support for NFS for Vagrant on Windows.
Other
567 stars 62 forks source link

Mounting problem on Windows 8.1 #12

Closed billmn closed 5 years ago

billmn commented 10 years ago

I'm using Laravel Homestead box ( http://laravel.com/docs/homestead ) and your awesome plugin to allow NFS on WIndows 8.1 Pro but I have some problem on mounting folders.

I've changed this line to force to use NFS on Windows https://github.com/laravel/homestead/blob/master/scripts/homestead.rb#L45

But when I run "vagrant up" I see this: nfs_error

Thoughts?

GM-Alex commented 10 years ago

Disable your firewall and check if the winnfsd process is running.

billmn commented 10 years ago

I've disabled Windows Firewall and checked task manager ... winnfsd.exe (32bit) running.

But the error is the same

GM-Alex commented 10 years ago

You could login to your box and try to run the command mount -o 'vers=3,udp,nolock' 192.168.10.5:'/C/www/projects' /home/vagrant/Code manually and play with the parameters like

mount -o 'vers=2,udp,nolock' 192.168.10.5:'/C/www/projects' /home/vagrant/Code mount -o 'vers=3,nolock' 192.168.10.5:'/C/www/projects' /home/vagrant/Code mount -o 'vers=4,udp,nolock' 192.168.10.5:'/C/www/projects' /home/vagrant/Code

billmn commented 10 years ago

I've tried some commands on Ubuntu ... here commands responses: cmd_resp

billmn commented 10 years ago

Oh I forgot to specify what I use:

Vagrant 1.6.3 and VirtualBox 4.3.12 r93733

Host Machine: Windows 8.1 Pro x64 Guest Machine: Ubuntu Ubuntu 14.04

GM-Alex commented 10 years ago

Could you search for the batch file nfsservice.bat and change the line

start "" "%~dp0winnfsd" -log off -pathFile %2 -id %3 %4

to

start "" "%~dp0winnfsd" -log on -pathFile %2 -id %3 %4

That will keep the window for the nfs daemon open and we can see what happens.

borisschapira commented 10 years ago

I did that, modified my VagrantFile nfs_setting condition to :

nfs_setting = RUBY_PLATFORM =~ /darwin/ || RUBY_PLATFORM =~ /linux/ || Vagrant.has_plugin?("vagrant-winnfsd")

and launched vagrant up.

The process freezes on

==> default: Mounting NFS shared folders
GM-Alex commented 10 years ago

@borisschapira And than you get a timeout?

borisschapira commented 10 years ago

@GM-Alex Nope, nothing. I tried to relaunch, same issue. 4 minutes waiting, still counting.

GM-Alex commented 10 years ago

Could you try to switch the logging on as suggested above and post the output? Do you have the firewall rules set up correctly?

borisschapira commented 10 years ago

My guest is a Debian :

Linux version 3.2.0-4-amd64 (debian-kernel@lists.debian.org) (gcc version 4.6.3 (Debian 4.6.3-14) ) #1 SMP Debian 3.2.46-1

And here is what I got, executing the first command :

windows powershell

borisschapira commented 10 years ago

And then I got the same message than @billmn 10 days ago.

GM-Alex commented 10 years ago

Oh there was a : missing, I changed the comment above. But could you please change also the nfsservice.bat (search for it on your windows machine) file.

borisschapira commented 10 years ago

Ok, so let's try again :

  1. I've created a www folder inside C:, with my project files
  2. I've relaunched vagrant up, I've got the freeze described above
  3. I've logged myself in, and tried :
sudo mount -o 'vers=3,udp,nolock' 192.168.10.5:'/C/www/' /var/www/

Response :

mount.nfs: Connection timed out
  1. I've tried again, with -v for verbose mode :
mount: no type was given - I'll assume nfs because of the colon
mount.nfs: timeout set for Fri Jun 20 13:47:24 2014
mount.nfs: trying text-based options 'vers=3,udp,nolock,addr=192.168.10.5'
mount.nfs: prog 100003, trying vers=3, prot=17
mount.nfs: portmap query failed: RPC: Timed out
mount.nfs: trying text-based options 'vers=3,udp,nolock,addr=192.168.10.5'
mount.nfs: prog 100003, trying vers=3, prot=17
mount.nfs: portmap query failed: RPC: Timed out
...
borisschapira commented 10 years ago

I forgot to write it by playing with the parameters did not work either. Maybe I did not understand. For example, where does the 192.168.10.5 IP come from ? Maybe I should change it by another...

GM-Alex commented 10 years ago

Could you please update to version 1.0.8, turn on the logging of the module as described in the readme and paste the output of the winnfsd daemon window.

borisschapira commented 10 years ago

I've updated ton version 1.0.8 and added to my VagrantFile

config.winnfsd.logging = "on"

How can I display the winnfsd daemon window ? A vagrant up is not showing any additionnal window, it only freezes as usual...

borisschapira commented 10 years ago

I looked inside the nfsservice.bat and I think there is an issue. I tried a nfsservice.bat start command. Output :

:==winnfsd.exe était inattendu.

(my system is in french, "était inattendu" means "unexpected")

I did not understand the message, si I played with the script, echoing %result% juste before the line

if %1==status (

Output :

information :
:==winnfsd.exe était inattendu.

As you can see, my %result% end with a : and contains a space. I think it can make the evaluation below erroneous. So I tried a simpler version of the script :+1:

@echo off

:: Fancy way to enable command extensions, where available
:: http://technet.microsoft.com/en-us/library/bb491001.aspx OR http://www.robvanderwoude.com/allhelpw2ksp4_en.php#SETLOCAL
verify other 2>nul
    setlocal enableextensions
    if errorlevel 1 echo Unable to enable command extensions

for /f "tokens=1 delims= " %%y in ('tasklist /nh /fi "imagename eq winnfsd.exe"') do @set result=%%y

if %result%==winnfsd.exe (
    echo "It worked !"
)

exit 1

And the output was :

:==winnfsd.exe était inattendu.

So I think I've nailed an issue, haven't I ?

borisschapira commented 10 years ago

I think that you should put " around your strings variable when evaluating. This works :

@echo off

:: Fancy way to enable command extensions, where available
:: http://technet.microsoft.com/en-us/library/bb491001.aspx OR http://www.robvanderwoude.com/allhelpw2ksp4_en.php#SETLOCAL
verify other 2>nul
    setlocal enableextensions
    if errorlevel 1 echo Unable to enable command extensions

for /f "tokens=1 delims= " %%y in ('tasklist /nh /fi "imagename eq winnfsd.exe"') do @set result=%%y

if "%result%"==winnfsd.exe (
    echo "Winnfsd is started"
) else (
    echo "Winnfsd is not started"
)

exit 1
borisschapira commented 10 years ago

With the modification above, the Mounting do not freeze anymore and the NFS daemon window is launched. When I try to access some files, the NFS deamon shows me a lot of NFS LOOKUP, NFS ACCESS, NFS GETATTR... so I think it works !

borisschapira commented 10 years ago

The nfsservice.bat did not worked well without quotes on both sides of the ===, telling me winnfsd.exe was not running when he was.

borisschapira commented 10 years ago

With the file contributed as above, I changed my config to

config.winnfsd.logging = "off"

My vagrant up output is now :

==> default: Configuring and enabling network interfaces...
==> default: Exporting NFS shared folders...
==> default: Preparing to edit nfs mounting file.
[NFS] Status: halted
[NFS] Start: started
==> default: Mounting NFS shared folders...
==> default: Mounting shared folders...
    default: /vagrant => C:/Users/Boris/Documents/GitHub/aquitaine
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: to force provisioning. Provisioners marked to run always will still run.

Isn't that very good :+1: ?

borisschapira commented 10 years ago

Now that I've managed to host a CentOS, I'm trying to host an Ubuntu 12.03 on Windows 8.1. It's my only Virtual Machine running.

Here is my VagrantFile Synced folders :

config.vm.synced_folder "salt/roots/", "/srv/", :nfs => not_windows
config.vm.synced_folder "salt/roots/salt/apache2/html-default", "/var/www/html/default/", :nfs => nfs_setting

if Dir.exists?('projects/project1/')
    puts 'Binding projects/project1/' 
    config.vm.synced_folder "projects/project1/", "/var/www/html/project1/", :nfs => nfs_setting
end

I've got the already known issue on vagrant up :

==> default: Mounting NFS shared folders...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

mount -o 'vers=3,udp,nolock' 10.0.0.1:'/C/www' /var/www/html/

Stdout from the command:

Stderr from the command:

stdin: is not a tty
mount.nfs: access denied by server while mounting 10.0.0.1:/C/www

So I connected directly to the VM and tried to run the mounting command myself, here is the response :

vagrant@gsoi:~$ sudo mount -o 'vers=3,nolock' 10.0.0.1:'/C/www/projects/project1' /var/www/html/project1 --verbose
mount: no type was given - I'll assume nfs because of the colon
mount.nfs: timeout set for Thu Jun 26 10:06:02 2014
mount.nfs: trying text-based options 'vers=3,nolock,addr=10.0.0.1'
mount.nfs: prog 100003, trying vers=3, prot=6
mount.nfs: trying 10.0.0.1 prog 100003 vers 3 prot TCP port 2049
mount.nfs: prog 100005, trying vers=3, prot=17
mount.nfs: trying 10.0.0.1 prog 100005 vers 3 prot UDP port 1058
mount.nfs: mount(2): Permission denied
mount.nfs: access denied by server while mounting 10.0.0.1:/C/www/projects/project1

And when I look the winnfsd daemon, I see a list of all known pathes (including the two above) and then :

MNT from 10.0.0.157
Final local requested path: C:\www\salt\roots\salt\apach2\html-default

NFS GETATTR C:\www\salt\roots\salt\apache2\html-default OK

So it seems the first Synced Folder is correctly mounted and there's an issue on the second folder to sync. Am I right ?

GM-Alex commented 10 years ago

New release online. Should be fixed now. @borisschapira Thanks again for your help.

borisschapira commented 10 years ago

@GM-Alex Thank you !

borisschapira commented 10 years ago

I still have the issue described above but I am not able to tell if the issue is Windows-related or related to the special multi-project configuration that I have.

If you want to test it, here is a complete Vagrant install to test : https://www.dropbox.com/s/dvxb8l47uaagyms/vagrantTest.zip Extract, and vagrant up --provision

pgcd commented 10 years ago

I have the same issue - two synced folders, one of which is handled correctly while the other returns an "access denied by server" error. Please note that, in my case, it's a sibling folder - the Vagrantfile is in workspace/A (which mounts correctly) and the second folder is workspace/B.

borisschapira commented 10 years ago

@GM-Alex Maybe you should reopen the issue, or make a new one for that "multiple folders" thing... My issue and the one of @pgcd seems to be the same...

## First folder, correctly managed
config.vm.synced_folder "salt/roots/", "/srv/", :nfs => nfs_setting

## Other folders, error
if Dir.exists?('projects/mawDevs/')
  config.vm.synced_folder "projects/mawDevs/", "/var/www/maw/", :nfs => nfs_setting
end

(extracted from https://github.com/MakeAWish/mawVagrant/blob/master/Vagrantfile)

Arttii commented 10 years ago

On my machine I also cannot handle multiple folders. If i share one folder it gets synced nicely, but otherwise no. Also I have to kill the process by hand with each vagrant reload not to get the permission error every time.

gigablox commented 10 years ago

Any updates on this? Facing this issue as well...

dariuszz123 commented 10 years ago

Manage templorary solve the issue. Workaround is just change absolute path to relative like: "D:/vagrant/project" -> "./project" (project should be in vagrant folder going back "./../project" not working).

Arttii commented 10 years ago

Ya this only works out properly with the relative path to the root vagrantfile dir and you need to use one sync point.

borisschapira commented 9 years ago

@dariuszz123 @Arttii I don't understand but I'm interested. This does not seem to work proprerly :

config.vm.synced_folder "./salt/roots/", "/srv/", :nfs => nfs_setting
config.vm.synced_folder "./projects/mawDevs/", "/var/www/maw/", :nfs => nfs_setting

Can you share your configuration, so that I can adapt my VagrantFile ?

Arttii commented 9 years ago

Well i have to configs, that work properly. One is a bit complicated, but set the nfs settings.

 config.vm.synced_folder ".", "/vagrant", disabled: true
 config.vm.synced_folder '.\\workspace', "/var/workspace", id: "core", :nfs =>    true,  :mount_options      => ['nolock,vers=3,udp'],  :'create-as-user' => true, :perms  => "u=rwx:g=rwx:o=rD", :'create-with-perms' => "u=rwx:g=rwx:o=rD", :'chown-  ignore' => true, :'chgrp-ignore' => true, :'chmod-ignore' => true

Second one is fairly simple. Vagrant it seems will default to nfs if you have winnfsd installed

 config.vm.synced_folder ".", "/vagrant", disabled: true
 config.vm.synced_folder '.\\workspace', '/var/workspace', mount_options: ["fmode=666"]

Your problem is you are using two synced folders, that just does not work currently consistently it seems. I spent days on this and in the end use on folder, which I can honestly live with by using symbolic links and such.

borisschapira commented 9 years ago

Ok I understand : you did not success synchronizing more than one folder so, in fact, you synchronize one folder and use symlink to do the magic. This does not correct the issue, but its a pretty effective workaround, thanks.

Arttii commented 9 years ago

Yes, as I said only consistent solution is to use one sync point. With my first method you can do multiple folders, but it sometimes works sometimes does not, the behavior is fairly sporadic.

phazei commented 9 years ago

I'm having this issue as well. Worked just fine on my work computer, but at home it just fails, I can't get it to mount even a single folder with NFS. I'm using Laravel Homestead as well.

It fails while provisioning and while the box is left running, I can't even SSH because it fails before it sets the keys I think. Just asks for the vagrant user pw.

I found this: https://github.com/coreos/coreos-vagrant/issues/159 And wasn't sure if it's related, but it's a similar issue, maybe could help, could it be a vagrant issue?

worthwhileindustries commented 9 years ago

+1

GM-Alex commented 9 years ago

@phazei Are you using a username with a space at the pc where it doesn't work?

willmorgan commented 9 years ago

IIRC If you set the VAGRANT_HOME environment variable to another dir (maybe under C:\HashiCorp\Vagrant\home, for example), you can sidestep that problem.

GM-Alex commented 9 years ago

Yes totally right. But I'm wondering that it works on one pc and it doesn't on an other. So the user name could be the issue. That's why I'm asking.

worthwhileindustries commented 9 years ago

no i am not using a username with a space in it. i'm using a multi-vm setup with 3 vms and several mounts on each. seems to work ok with one mount and is wicked fast when running unit tests now.

the symbolic link workaround is not an option

is the limitation of having one mount a limitation of winnfsd or a limitation of the plugin's implementation of it?

worthwhileindustries commented 9 years ago

i'll do some more testing and I'll update... thanks.

worthwhileindustries commented 9 years ago

Ok I have verified you can have multiple nfs mounts with this plugin on the same box for anyone who said that this does not work or is unsure if that's why they are having issues mounting. However, I'm having another issue with

The following SSH command responded with a non-zero exit status. Vagrant assumes that this means the command failed!

mount -o 'vers=3,udp,nolock' 10.33.33.1:'/C/test/vm/mercurial_testing' /vagrant_reporting_test Stdout from the command: Stderr from the command: mount.nfs: access denied by server while mounting 10.33.33.1:/C/test/vm/mercurial_testing

It's strange because it works on some folders in the same directory and doesn't work on others. I can't verify what's different between the folders. Tried making new folders within the directory as well as adding new folders to the directory and adding them to the repo. It must be a permissions thing that I am not seeing.

worthwhileindustries commented 9 years ago

Yep plugin seems to be fine unless it's the thing causing the permissions problems. Great plugin. My unit tests went from taking 8+ minutes to under 2 minutes. If I figure out what is causing these permissions issues I'll update the ticket.

andrewmatthews commented 9 years ago

I am not sure if this helps, but when I run winnfsd.exe manually, it binds to the public IP address of my machine, and does not respond to any other IP addresses (including the ones allocated by Vagrant). This is also the case when Vagrant starts winnfsd.exe.

There does not seem to be an option to specify which IP address to bind to.

pgcd commented 9 years ago

I suspect the problem has something to do with the plugin trying to re-use the same credentials/connection. The last time I tried to use this kind of setup I hacked around a bit with the plugin, starting the service manually and printing everything I could think of, and there was some kind of conflict when the plugin registered the second share. Unfortunately, since I couldn't solve the problem right away, I eventually reset everything and went a different route - without taking notes - so this information is less than useful. but hopefully it can help with getting to the root cause.

worthwhileindustries commented 9 years ago

@andrewmatthews @pgcd yeah it is helpful at least to know other people are having it and it's not just my setup. Winnfsd 2.0 is really old. Does anyone know if M$ has any plans to bring NFS to Windows natively? Anyway, I will do some more tests before completely giving up. Thanks

worthwhileindustries commented 9 years ago

[NFS] Status: running ==> sa_web: Mounting NFS shared folders... The following SSH command responded with a non-zero exit status. Vagrant assumes that this means the command failed! mount -o 'vers=3,udp,nolock' 10.33.33.1:'/C/vm/application_suite' /vagrant_web Stdout from the command: Stderr from the command: mount.nfs: access denied by server while mounting 10.33.33.1:/C/vm/application_suite

Is there a way to see a log from winnfsd or a log from windows as to why the access would be denied? I had to kill the winnfsd.exe process and do a vagrant up on the same VM it worked fine.

phazei commented 9 years ago

@GM-Alex No spaces in either username.

I've pretty much given up on it at home, maybe I'll try again this week. I did disable the NFS to get the vagrant box provisioned the first time. Then enabled it when I could boot into the box. I noticed that sometimes it would work the first time, but then never again. When it did work, it would eventually die and in the virtual box, the files would be listed, but with ???? for all the properties and an indication that it didn't exist what I tried to do anything with the file. Would have to reboot the box, but then the NFS would fail entirely.

Both computers are running Win7. The work computer I installed the windows tools for unix systems before hand before I even found winNFSd. At home I installed it afterwards to see if it would fix anything, but it didn't.