winnfsd / vagrant-winnfsd

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

winnfsd as a service #77

Open Alexwijn opened 8 years ago

Alexwijn commented 8 years ago

Is it possible to use the plugin as a permanent running service rather than having a window open in the background with winnfsd.exe?

Ps. I'm running Homestead

HollyIT commented 8 years ago

I actually just did something like this after having problems of files not updating, plus having numerous boxes with varying share paths. The trick wasn't all that hard:

Since doing that I haven't had any problems with files not refreshing either. Before I was having it happen after a few hours of usage. Right now the VM and WINNFSD has been up over 72 hours with no problem.

lecajer commented 8 years ago

@HollyIT Your trick ounds promissing, can you share some of your text file with the share ? How is vagrant linked with these shares ?

HollyIT commented 8 years ago

There is no "link". You're just using native NFS in Vagrant as if you were on a Linux or OSX host. For the text file, it's very simple. Just make a text file and put the folders you want to share in it (same as the source folders in your vagrant file), one on each line. IE:

C:\MyShares\folder1 D:\OtherShares\folder2

You don't even have to change anything in your vagrant file if you've been using the plugin. That's already configured.

Then using the .bat file from the winnfsd repository, simply execute:

nfsservice.bat start {{absolute path to your file}} <--- must be the absolute path.

I've got everything in a C:\winnfsd folder:

Now all I got to do is go to C:\winnfsd and execute nfsservice.bat start C:\winnfsd\exports.txt (actually I set up short cuts to start and stop on my desktop just to be lazy).

lecajer commented 8 years ago

Thanks, I'll try How does your exports.txt looks like ?

In my vagrantfile I got my.vm.synced_folder ".", "/my/dev", id: "dev", :nfs => true

HollyIT commented 8 years ago

You would have to put the full path in the txt file. So if your vagrant file is in C:\vagrant\machines\machine1, put that in the text file. You might want to update your vagrant config's source file to absolute as well. FYI - the list I gave above is how my txt file looks. I just changed the paths to generic names.

lecajer commented 8 years ago

I removed the plugin vagrant plugin remove vagrant-winnfsd

When I run nfsservice.bat start "C:/path/exports.txt" (as admin) via windows command promt it tels me that "grep" command is not found

When I run nfsservice.bat via gitbash (yeah I tried) it says that it does not know @echo

I directly launched via windows command winnfsd.exe "C:/path/exports.txt" Also tried with winnfsd.exe "C:/path/sharedfolder" winnfsd runs but on vagrant up I get

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` dev /ass/dev
mount -t vboxsf -o uid=`id -u vagrant`,gid=`id -g vagrant` dev /ass/dev

The error output from the last command was:

/sbin/mount.vboxsf: mounting failed with the error: No such device
HollyIT commented 8 years ago

Ahhh didn't notice they were using GNU commands. You can either install something like Cygwin, which gives you the GNU commands in Windows, or open a ticket on the winnfsd project to see if they can modify the batch to use Windows commands.

lecajer commented 8 years ago

Ok will try next week. Do you think that we must use the bat file to make it work with Vagrant. What about my try with winnfsd.exe directly ?

HollyIT commented 8 years ago

Sure. You'll just have to make sure to not close the command window doing that, or it will kill the process. The WinNFSD project page has examples on it. https://github.com/winnfsd/winnfsd

joharohl commented 8 years ago

Hey @HollyIT. I have been trying to do what you are doing. Running winnfsd by itself is fine, but removing the winnfsd plugin makes vagrant mount shares as virtualbox shares even though they are marked as nfs. Running cat /proc/mounts on the VM shows that the mounts are of type vboxsf not nfs. Have you mounted your shares manually? Or does vagrant actually mount the nfs shares for you?

lecajer commented 8 years ago

+1 @joharohl

joharohl commented 8 years ago

@Jeremlicious, I managed to get something working. Please see this gist: https://gist.github.com/joharohl/21e5f6bbc9e5f8787688

It's not the neatest solution most likely, but it does the job. For whatever reason, my winnfsd hangs when using normal windows paths so I have to use the thing with the questionmark at the beggining (and escaping the backslash in the Vagrantfile).

Good luck!

HollyIT commented 8 years ago

I had actually noticed there was still a version of the plugin running in my Vagrant. I still use this method because it gave me an easy way to kill off the winnfsd.exe process when starting another box (there's an issue in winnfsd.exe on having more than 1 mount point causing it to error out). The actual Vagrant plugin checks when a machine is booting that winnfsd.exe is running and if it is gets a mount listing from winnfsd. If that mount isn't listed, then it adds it to its own exports file and restarts. If it is mounted, then it just continues on.

Even then, I still get the files not refreshing problem from time to time. Luckily now I can simply click my shortcut to stop and then start the service, then I've got a bash script on each of my machines to do a umount and mount to remount the path. Still dirty, but a lot quicker than shutting down the VM and restarting it.

natgateway commented 8 years ago

@Jeremlicious

I was looking around for the native powershell or windows equivalent of the GNU commands in the nfsservice.bat file, as I don't have those installed either and am trying to get this to work with native tools if possible. tried using

tasklist /nh /fi "imagename eq winnfsd.exe" 2>nul | (findstr -N "winnfsd.exe"| find /c":") >nfsservicetmp

instead of

tasklist /nh /fi "imagename eq winnfsd.exe" 2>nul | grep -i -c "winnfsd.exe" >nfsservicetmp

on the second line of the nfsservice.bat file, it seemed to work to get the service started, although I am still figuring out the rest on how to get vagrant running on my windows host.

Also replacing "printf" with echo in that .bat file may help to avoid any further errors if, like me, you don't have cygwyn or other utilities installed.

I hope that helps.

garbinmarcelo commented 6 years ago

any news?