Re: [systemd-devel] systemd-udevd seems to kill mount.ntfs started in rules scripts?
On Thu, 03.04.14 16:13, Barry Scott (barry.sc...@onelan.co.uk) wrote: > More of my porting from F16 to F20. > > I have the following in /etc/udev/rules.d > > ACTION=="add", SUBSYSTEM=="block", SUBSYSTEMS=="usb", > RUN+="/usr/local/onelan/ntb/bin/ntb_mount_usb" > ACTION=="remove", SUBSYSTEM=="block", SUBSYSTEMS=="usb", > RUN+="/usr/local/onelan/ntb/bin/ntb_mount_usb" > > This run the ntb_mount_usb script as expected. > > The script on the ADD action ends up doing: > > mount -t ntfs -o uid=onelan,gid=onelan,noatime,noexec ${DEVNAME} /my-mount- > point As mentioned by others in this trhead, you need to invoke such scripts as systemd units, as we'll kill all remaining worker processes after we are done with all the work from udev. Also note that very recent udev versions will run in their own mount namespace, which disables propagation of mounts from udev to the host. Hence, if you want to mount something from udev, the best approach is to simply use nofail in fstab, and if you need more complex matches pulling in the .mount unit via SYSTEMD_WANTS from an udev rule. Lennart -- Lennart Poettering, Red Hat ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] systemd-udevd seems to kill mount.ntfs started in rules scripts?
On Thu 03 Apr 2014 17:27:44 Thomas Bächler wrote: > Am 03.04.2014 17:13, schrieb Barry Scott: > > But as soon as the script exits the mount.ntfs process is killed off by > > something? systemd-udevd maybe? > > From man udev's section on RUN: > > " This can only be used for very short-running foreground > tasks. Running an event process for a long period of time may block all > further events for this or a dependent device. > >Starting daemons or other long-running processes is not > appropriate for udev; the forked processes, detached or not, will be > unconditionally killed after the event handling has finished." > > Instead of using RUN, use SYSTEMD_WANTS to start a .mount or .service > unit that does your job. In the remove case, use > RUN+="/usr/bin/systemctl stop --no-block foo.mount" or similar. > > (Not that I think this is a good idea at all: Your volume will be > "unmounted" after it has been remove already - you are asking for data > corruption.) I did not set out to run a daemon. Its looks on the surface like I'm just mounting a device. It was a partial a surprise that the mount.ntfs process was considered part of the udev CG (but I not sure where else it might be put). What I have done is created a service that does the mount and umount actions triggered by the udev rule. I need the udev rule as I have cannot depend on any of the important properties of the USB device, its name, the FS type etc. I'm not using the template mechanism, but will investigate it. Barry ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] systemd-udevd seems to kill mount.ntfs started in rules scripts?
2014-04-03 17:13 GMT+02:00 Barry Scott : > How should I be doing this? As I don't know if your script is meant to mount arbitrary removable drives, if you just want to mount a specific device, the simplest solution is to just add it to /etc/fstab. Use somehting like UUID or LABEL to identify it, and make sure to use auto + nofail. systemd will automatically mount the device -- Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth? ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] systemd-udevd seems to kill mount.ntfs started in rules scripts?
2014-04-03 17:27 GMT+02:00 Thomas Bächler : > Am 03.04.2014 17:13, schrieb Barry Scott: >> But as soon as the script exits the mount.ntfs process is killed off by >> something? systemd-udevd maybe? > > From man udev's section on RUN: > > " This can only be used for very short-running foreground > tasks. Running an event process for a long period of time may block all > further events for this or a dependent device. > >Starting daemons or other long-running processes is not > appropriate for udev; the forked processes, detached or not, will be > unconditionally killed after the event handling has finished." > > Instead of using RUN, use SYSTEMD_WANTS to start a .mount or .service > unit that does your job. In the remove case, use > RUN+="/usr/bin/systemctl stop --no-block foo.mount" or similar. I wouldn't do that. If you need that, simply bind the .service to the device via BindsTo. -- Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth? ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] systemd-udevd seems to kill mount.ntfs started in rules scripts?
2014-04-03 17:13 GMT+02:00 Barry Scott : > More of my porting from F16 to F20. > > > > I have the following in /etc/udev/rules.d > > > > ACTION=="add", SUBSYSTEM=="block", SUBSYSTEMS=="usb", > RUN+="/usr/local/onelan/ntb/bin/ntb_mount_usb" > > ACTION=="remove", SUBSYSTEM=="block", SUBSYSTEMS=="usb", > RUN+="/usr/local/onelan/ntb/bin/ntb_mount_usb" > [..] > But as soon as the script exits the mount.ntfs process is killed off by > something? systemd-udevd maybe? Long running process should not be run from udev rules. If udev is run under systemd it will kill such processes after a timeout (I think it was 120 secs) > How should I be doing this? You could use something like udevil or udisks-glue. If you want to do it via udev/systemd, use SYSTEMD_WANTS ACTION=="add", SUBSYSTEM=="block", SUBSYSTEMS=="usb", TAG+="systemd", ENV{SYSTEMD_WANTS}+="foo.service" Then write a foo.service which does the actual mount. You can pass additional information to the service if you use a template -- Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth? ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] systemd-udevd seems to kill mount.ntfs started in rules scripts?
Am 03.04.2014 17:13, schrieb Barry Scott: > But as soon as the script exits the mount.ntfs process is killed off by > something? systemd-udevd maybe? From man udev's section on RUN: " This can only be used for very short-running foreground tasks. Running an event process for a long period of time may block all further events for this or a dependent device. Starting daemons or other long-running processes is not appropriate for udev; the forked processes, detached or not, will be unconditionally killed after the event handling has finished." Instead of using RUN, use SYSTEMD_WANTS to start a .mount or .service unit that does your job. In the remove case, use RUN+="/usr/bin/systemctl stop --no-block foo.mount" or similar. (Not that I think this is a good idea at all: Your volume will be "unmounted" after it has been remove already - you are asking for data corruption.) signature.asc Description: OpenPGP digital signature ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] systemd-udevd seems to kill mount.ntfs started in rules scripts?
More of my porting from F16 to F20. I have the following in /etc/udev/rules.d ACTION=="add", SUBSYSTEM=="block", SUBSYSTEMS=="usb", RUN+="/usr/local/onelan/ntb/bin/ntb_mount_usb" ACTION=="remove", SUBSYSTEM=="block", SUBSYSTEMS=="usb", RUN+="/usr/local/onelan/ntb/bin/ntb_mount_usb" This run the ntb_mount_usb script as expected. The script on the ADD action ends up doing: mount -t ntfs -o uid=onelan,gid=onelan,noatime,noexec ${DEVNAME} /my-mount- point I have had the script do ps afx and systemd-cgls and see the mount.ntfs process is running. ├─systemd-udevd.service │ ├─ 409 /usr/lib/systemd/systemd-udevd │ ├─14863 /usr/lib/systemd/systemd-udevd │ ├─14867 /usr/lib/systemd/systemd-udevd │ ├─14868 /usr/lib/systemd/systemd-udevd │ ├─14869 /usr/lib/systemd/systemd-udevd │ ├─14876 /bin/bash /usr/local/onelan/ntb/bin/ntb_mount_usb │ ├─14886 /sbin/mount.ntfs /dev/sdb1 /data/data/external/USB_Memory_Stick -... │ └─14890 systemd-cgls But as soon as the script exits the mount.ntfs process is killed off by something? systemd-udevd maybe? How should I be doing this? Barry ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel