This question already has an answer here:

When I used INotify with /etc/mtab or /proc/mounts, it doesn't detect changes when things mount or unmount, even though /etc/mtab and /proc/mounts both have changed when I check manually. Why is this, and how can I track mounting and unmounting things?

marked as duplicate by Celada, Jakuje, Scott, Gilles, Shawn J. Goff Mar 6 '16 at 0:14

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • The duplicate is alsa-themed so not an exact match, but it does answer the question of why inotify doesn't work under /proc. As supplementary information, there is no alternate interface that I know of that will fire events that you can subscribe to when filesystems are mounted and unmounted. I've searched for it before. – Celada Mar 5 '16 at 21:45
  • 1
    stat /etc/mtab will tell you why the other answer is completely relevant – Shawn J. Goff Mar 6 '16 at 0:14

From the inotify man page:

various pseudo-filesystems such as /proc, /sys, and /dev/pts are not monitorable with inotify.

and /etc/mtab is often just a link to /proc/mounts these days. You can use udisksctl monitor to see mounts happen, or set your own /etc/udev/rules.d/ rule file to run a program when a new device is added (before any mount), or run dbus-monitor to see mount events pass on that bus. All a bit complicated.

Not the answer you're looking for? Browse other questions tagged or ask your own question.