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?
Asked
Active
Viewed 1,095 times
4

Gilles 'SO- stop being evil'
- 829,060

Christopher King
- 636
1 Answers
5
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.

meuh
- 51,383
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 05 '16 at 21:45stat /etc/mtab
will tell you why the other answer is completely relevant – Shawn J. Goff Mar 06 '16 at 00:14