[systemd-devel] systemctl and detach in udev RUN

Albert Strasheim fullung at gmail.com
Wed Oct 5 07:10:06 PDT 2011


Hello all

I have the following udev rule in a machine with a bunch of disks:

SUBSYSTEM=="block", KERNEL=="sd*", TAG+="systemd", ACTION=="add",
RUN+="/bin/systemctl restart blockinit@%k.service"

The blockinit service is a one-shot service that runs a program that
checks if the block device matches some criteria (right size, etc.),
formats it (if it doesn't have the right file system yet), fscks it
(always) and mounts it.

I always want this service to restart if a block device is added,
because I want to deal with block devices that are unplugged and
replugged, etc.

Since it always fscks, the systemctl restart of the service takes
about 20-30 seconds to complete.

However, the udev manual page says:

RUN
- Add a program to the list of programs to be executed for a specific device.
- This can only be used for very short running tasks.
- Long running tasks need to be immediately detached from the event
process itself.

Is there a way systemd can help me to do this "detaching"?

Regards

Albert


More information about the systemd-devel mailing list