Lennart Poettering <lennart@xxxxxxxxxxxxxx> writes: > It prevents it fully. However, udev installs an inotify watch on all > relevant block devices, which watches for IN_CLOSE_WRITE events, and > then triggers the device again. IN_CLOSE_WRITE is the event that is > generated when an inode is closed after it was open for writing. For > block devices this means that when tools such as fdisk open the device > for writing and then close it, the devices will be fully automatically > reprobed afterwards (unless a BSD file lock is still in place then, by > somebody else). > > IN_CLOSE_WRITE is strictly speaking not the event we *actually* want > to watch for retriggering the device (that would be an event triggered > by the release of the file lock, but linux does not support generating > a lock then), but it's really close, because "close-after-write" and > "release lock" typically coincide, or are even the very same > operation. So if you want to prevent automounting entirely you have to... open the disk device read only and take the bsd lock, and hold it until after closing the write file descriptor? Plus probably a little more time to give udev a chance to try and fail to take the lock? Then again, this will also prevent the udevdb from being updated. Maybe that is a bigger hammer than you really want when the goal is just to stop auto mounting?