Skip to content

Use systemd.device units instead of running systemctl enable/disable #112

Open
@commiterate

Description

Description

systemd supports device units (systemd.device) which are dynamically created/deleted/reloaded on device hot-attach/hot-detach/change.

Update the udev rules and systemd unit files to use this instead of systemctl enable/disable.

Background

The current udev rules create/delete + start/stop systemd units by running systemctl enable/disable --now on ENI hot-attach/detach.

This is undesirable for a few reasons:

  1. It doesn't work in distributions with an immutable /etc/systemd/system (e.g. NixOS).
    • systemctl enable/disable creates/deletes symlinks to systemd unit files elsewhere on the system (e.g. /lib/systemd/system) in /etc/systemd/system.
  2. Interface-specific units are started automatically on reboot by systemd without input from udev.
    • If an instance is stopped, an ENI is detached, and the instance is started, there may be zombie service and timer units until udev emits a remove event (if it does it at all. It might not if there's a power outage or the system crashes and the ENI is removed before the subsequent boot).

Even without switching to systemd.device units, the udev rules should be doing systemctl start/stop instead of systemctl enable/disable.

See NixOS/nixpkgs#355111 (comment) for a more detailed discussion.

Notes

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions