Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
systemd-udevd.service not responding to PrivateMounts or MountFlags #11982
systemd version the issue has been seen with
Expected behaviour you didn't see
Many users want to add udev rules to automatically mount removable devices when attached.
However, Udev by default runs in a separate mount namespace.
The workaround should be documented somewhere easy to find.
In the above SE post, some users reported that creating an override file for the Udev service, with
was successful. However, this does not work for me, and another SE user reported the same.
I also tried editing the full Unit file:
This is related to #1741 - I am trying to find a better solution for dealing with removable drives, which doesn't use /etc/fstab.
I couldn't find information in
btw, pull in a .mount unit via SYSTEMD_WANTS from a device for this purpose, or even better use the
You mean as an alternative to calling 'mount' from a udev rule?
The solution I want
So some kind of script is going to be called. I guess udev rules could call the script directly, and then the script could call
Wow this issue is really getting cluttered with miscommunication. I'm sorry I should be keeping things simpler. I should have just stuck to asking "You mean [use systemd-mount] as an alternative to calling 'mount' from a udev rule?" which I think you just answered with "yes".
Also by commenting "everything after
I think I'll just stick with Ferk's solution, based on a simple Systemd service, which works fine. If I take a udev-rule/script combination which is able to 'mount' successfully (but where the mount disappears after a few seconds because Systemd kills the process) and then I replace the 'mount' command with 'systemd-mount', then what happens is it takes a very long time and seems to time out. The log file says I should check the journal, which has an entry like:
Strangely if I run
If your intention is for people to be automounting USB devices in
Oh, I got that
Then I got
referenced this issue
Mar 14, 2019
Thank you. The commit has:
One thing I don't understand is where the device gets mounted, i.e. how do I specify that it should be mounted in
See man page:
By default the mount point is below /run/media/system/ and a name derived from the fs label. you can tweak that however, by setting the SYSTEMD_MOUNT_WHERE udev prop (or specifiying a second arg to the systemd-mount cmdline)
It contains the device node path (i.e. /dev/xyz). The other two contain the kernel internal name, i.e. not a path.