[TriLUG] How to monitor mount point changes?
Ed Blackman via TriLUG
trilug at trilug.org
Mon Mar 9 20:15:27 EDT 2020
Is there a way to wait for mount point changes without polling?
I had an external disk fail over the weekend, and only noticed when jobs
that accessed the disk failed with weird errors, causing me to have to
debug back to the hardware failure.
As part of the response to the failures, Linux remounted the disk
read-only. I'd like to put monitoring in place so that if something
similar happens in the future, I'll get a clear "/mountpoint remounted
read-only" alert to point me more directly at what's wrong.
I can certainly create a systemd timer to run periodically and check for
unexpected read-only filesystems. But then I have to trade off the load
of polling frequently vs a delay due to polling infrequently, which I
would really prefer to block somehow waiting for changes to
/proc/mounts.
I tried a systemd path unit looking for PathModified for /proc/mounts
(also tried /proc/self/mounts based on some searching), but the
associated service didn't get triggered when I mounted or unmounted a
loopback device.
I tried using udevadm monitor, which did generate events on mount or
unmount, but not on "mount -o remount,ro /mountpoint".
Searching didn't turn up anything else. Is there some way to either
directly do this? If not, how do you get notified of such things?
--
Ed Blackman
More information about the TriLUG
mailing list