Solved

inotifywait on remote folder with local mount point

Posted on 2016-10-29
7
256 Views
Last Modified: 2016-10-31
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.
0
Comment
Question by:Steve Bink
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 16

Assisted Solution

by:Hanno P.S.
Hanno P.S. earned 100 total points
ID: 41865764
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
 
LVL 40

Expert Comment

by:noci
ID: 41865835
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
 
LVL 51

Author Comment

by:Steve Bink
ID: 41865923
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
Interactive Way of Training for the AWS CSA Exam

An interactive way of learning that will help you visualize core concepts so that you can be more effective when taking your AWS certification exam.  Built for students by a student to help them understand the concepts that they are being taught.

 
LVL 40

Assisted Solution

by:noci
noci earned 100 total points
ID: 41866085
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
 
LVL 51

Author Comment

by:Steve Bink
ID: 41866254
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
 
LVL 37

Accepted Solution

by:
ArneLovius earned 300 total points
ID: 41867662
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
 
LVL 51

Author Comment

by:Steve Bink
ID: 41867695
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

Featured Post

MongoDB Through a MySQL Lens

This article looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background Still having to process all these year-end "csv" files received from all these sources (including Government entities), sometimes we have the need to examine the contents due to data error, etc... As a "Unix" shop, our only readily …
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Suggested Courses

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question