0

I'd like to trigger file system events on a Linux virtual machine (VirtualBox). I'm not sure how to approach this, but I can imagine there could be 2 ways of doing it:

  • with a built-in command in the guest system
  • or from the host system controlling the guest through VirtualBox commands

I did some research and found tools like guard/listen, but I could not manage to make them work. (Guard asking for plugins and the documentation is not clear to me...)

My goal is not a new thing, I'd like to forward file system events from the host to the guest. On the host side I'm using fswatch to hook up to file system events. Fswatch would run a script on the guest system via SSH - that script/command could trigger an fs event in the guest system based on the parameter from fswatch which was a path... It's not an efficient approach I guess but for development purposes when I modify some files in the IDE should be good enough.

haxpanel
  • 3,270
  • 1
  • 30
  • 54
  • You can mount the filesystem from the host via NFS. – hek2mgl May 16 '16 at 13:41
  • It is mounted. The issue is fs events don't seem to be being forwarded properly. – haxpanel May 16 '16 at 13:42
  • I'm using webpack dev server with Hot Module Replacement. When make a change in a file from the host system HMR isn't updating / refreshing the browser. If I make the change in the guest system by logging in via SSH and nano edit that same file, my changes can be seen immediately in the browser. – haxpanel May 16 '16 at 13:46
  • Applications on Linux use inotify to monitor file system changes. I did some investigation and it seems like NFS does *not* support inotify. Sorry. Have you tried to mount the folder as normal VirtualBox shared directory and not NFS? I'm not sure if that works but it would be worth a try – hek2mgl May 16 '16 at 14:02
  • Unfortunately, VirtualBox have decided not to bother supporting the forwarding of events like this via Shared Folders: https://www.virtualbox.org/ticket/10660 -- I've just had the same idea that you're proposing and I'm planning to implement something (for an OSX host) simple just now, unless I can find this already existing. I'll update when I have something to share. – Ryan Long May 18 '16 at 14:23
  • Recently I made it work, check my answer. Hope that's gonna help you too. :) – haxpanel May 18 '16 at 15:06
  • Possible duplicate of [How to run a shell script when a file or directory changes?](https://stackoverflow.com/q/4060212/608639) – jww Jun 23 '18 at 05:34

1 Answers1

0

This one solved my problem: vagrant-notify-forwarder

haxpanel
  • 3,270
  • 1
  • 30
  • 54