inotifywait on remote folder with local mount point

I'm running a VirtualBox with Ubuntu, hosted on Windows 10.  I have an NTFS directory mounted as a VB shared folder.  From within the VM, I want to monitor this directory recursively for file changes and run a local shell script when one is detected.  

I'm familiar with inotifywait, but the file changes are being done from the host side, so the VM's file system does fire any events when a change is made.
LVL 51
Steve BinkAsked:
Who is Participating?
 
ArneLoviusConnect With a Mentor Commented:
If you run it the other way around and work in a SMB share from the Linux VM, then you could use inotifywait on the Linux side...

Alternatively, work locally and use something* to replicate to directory structure to the Linux VM, where you could use inotifywait

*I would suggest taking a look at syncthing
0
 
Hanno P.S.Connect With a Mentor IT Consultant and Infrastructure ArchitectCommented:
A notification can only happen on the side with the fs (locally).
Therefore, you have two options:
a) Get the notification on the server's side and send some inf/message to yout client (who has the fs mounted)
b) Create a small script that loops through a little check routine (polls for changes)
0
 
nociSoftware EngineerCommented:
A different approach might be: Supply the service from the linux box where the windows box does the remote mount..?

Another approach:
https://github.com/thekid/inotify-win

Inotify port for windows.
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
Steve BinkAuthor Commented:
To clarify the scenario a bit...

I code using PHPStorm on Windows.  My project is in a Windows directory.  My web services and runtime environment is a LAMP stack on my Ubuntu VM.  The Windows-based project directory is exposed to the VM as a VB shared folder, and the docroot for my Apache site is that same shared folder..  When files are changed in the project (e.g., I edit files), I want to fire a shell script on the VM to run some management tasks.  The script must have local access to the VM file system.

It sounds to me like I need a way for an Ubuntu VM to monitor the host filesystem for changes.  inotify-win looks promising, but I'm not sure how to get those messages into the guest.
0
 
nociConnect With a Mentor Software EngineerCommented:
Oh ok...
In that case you may want a different setup... using git.
Build your stuff on windows and create the layout as you want to have it on the LAMP environment.
Store that in git...
Then regularly pull the environment to the windows box.
If there are no changes no download will happen. (This is how many continuous sites update their stuff).

OTOH you can always trigger a pull by the windows version of inotify.
0
 
Steve BinkAuthor Commented:
As it is right now, when I edit a file on the host, the changes are immediately apparent from the guest.  The problem is that every time I edit a file, I want to run a script to update a deployment package to include the changes, and/or copy them into place in a "pre-deployed" testing environment. The final version of the entire thing (source and deploy package) may also be committed into a git repo and pushed.  All of that happens inside the guest... Windows is used only for editing.

Currently, I edit my files, then manually trigger this process on the VM.  It is that step I want to automate.  I've considered using a poller, but I think that would just end up being a source of stress... even if I polled every five seconds, that delay can interrupt my workflow just as much as pausing to trigger my deployment script.

>>> Supply the service from the linux box where the windows box does the remote mount..?

That sounds like a perfectly sane solution, though it grates against my inclination to have my Windows docs be the canon.  How could I implement that?
0
 
Steve BinkAuthor Commented:
It was while I was looking at syncthing that I remembered why I set it up this way... I'm trying to keep the space usage on the VM to a minimum.  So, I guess I'm just out of luck here.  

For the record, syncthing would have been a good solution here.  Its only deficiency is the fact that the guest would maintain its own copy.  Minus the space limitations, it would have been ideal.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.