systemd socket-activated service times out after moving /var to separate partition
Environment
Ubuntu 22.04 server running systemd 249 with /var moved to a dedicated ext4 LVM logical volume (fstab updated). A critical internal service uses systemd socket activation (mydaemon.socket → mydaemon.service).
Symptoms
After reboot the machine reaches multi-user.target but mydaemon never starts; systemctl status mydaemon shows 'loaded, inactive (dead)' and 'Socket unit mydaemon.socket is listening' with 'Startup finished in Xs (kernel)'. Attempts to start the service manually hang and eventually fail with a 90s timeout.
Observations
journalctl -b shows unit startup ordering: systemd starts mydaemon.socket before /var is mounted; logs include 'Failed to listen on socket: No such file or directory' pointing to /var/run/mydaemon.sock; fstab entry for /var uses UUID=... defaults, 0 2; 'systemctl list-dependencies multi-user.target' shows no explicit dependency from socket unit to local-fs.target; mounting /var manually and restarting the socket unit makes the service work immediately.
Already attempted
Edited mydaemon.service and mydaemon.socket to add After=local-fs.target and Wants=/var; reloaded systemd daemon and rebooted — no effect because the socket unit still activated too early. Tried adding x-systemd.automount to fstab for /var — caused different timing issues. Restored /var content to root filesystem (temporary) and service started normally.
Question
What is the minimal, reversible systemd unit or fstab change to ensure a socket‑activated service waits for /var to be mounted before systemd creates/listens on the socket? How can I avoid race conditions without moving /var back to the root filesystem?
Verified community troubleshooting
No answers yet..
Incident analysis
Most likely causes
Summary
Suggested Fixes
Continue troubleshooting
Related troubles
Matched from the title, description and tags
- Linux23% match
systemd service fails to start with status=203/EXEC for Node app after unit file change
Open0 answers - Linux22% match
Ubuntu 22.04 service fails to start after re-encrypting LUKS volume changed partition UUIDs
Open0 answers - Linux22% match
Docker containers lose DNS after host switched to systemd-resolved stub resolver on Ubuntu 22.04
Solved1 answer - Linux21% match
Ubuntu VMs jump 60–120 seconds ahead after live migration; systemd‑timesyncd reports large step adjustments
Open0 answers - Linux21% match
Ubuntu 22.04: Docker containers intermittently lose DNS after host switches to systemd-resolved stub resolver during network changes
Solved1 answer