I have the following content in in /etc/udev/rules.d/81-external-disk.rules:
ENV{ID_FS_UUID}=="6826692e-79f4-4423-8467-cef4d5e840c5", RUN{program}+="/bin/mount -o nofail,x-systemd.device-timeout=1 -t ext4 -U 6826692e-79f4-4423-8467-cef4d5e840c5 /backup/external"
After running:
udevadm control --reload ; udevadm trigger /dev/sdb1
It does nothing at all. However if II change the mount command for something such as /bin/touch /tmp/xyz it works.
Versions:
[root@helsinki rules.d]# rpm -qa | grep udev
libgudev1-219-19.el7_2.12.x86_64
python-pyudev-0.15-7.el7_2.1.noarch
[root@helsinki rules.d]# rpm -qa | grep systemd
systemd-libs-219-19.el7_2.12.x86_64
systemd-219-19.el7_2.12.x86_64
systemd-sysv-219-19.el7_2.12.x86_64
[root@helsinki rules.d]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
Best Answer
This is a systemd feature. The original
udev
command has been replaced bysystemd-udevd
(see its man page). One of the differences is that it creates its own filesystem namespace, so your mount is done, but it is not visible in the principal namespace. (You can check this by doingsystemctl status systemd-udevd
to get the Main PID of the service, then looking through the contents of/proc/<pid>/mountinfo
for your filesystem).If you want to go back to having a shared instead of private filesystem namespace, then create a file
/etc/systemd/system/systemd-udevd.service
with contentsor a new directory and file
/etc/systemd/system/systemd-udevd.service.d/myoverride.conf
with just the last 2 lines, i.e.and restart the systemd-udevd service. I haven't found the implications of doing this.