Skip to content

beesd@.service: add shutdown ordering to prevent EBUSY on unmount - #350

Open
linm-at wants to merge 1 commit into
Zygo:masterfrom
linm-at:fix/systemd-shutdown-ordering
Open

beesd@.service: add shutdown ordering to prevent EBUSY on unmount#350
linm-at wants to merge 1 commit into
Zygo:masterfrom
linm-at:fix/systemd-shutdown-ordering

Conversation

@linm-at

@linm-at linm-at commented Jun 18, 2026

Copy link
Copy Markdown

Without Before=umount.target, systemd has no ordering guarantee between
stopping beesd and unmounting the filesystems it holds open, causing
unmount failures with EBUSY during shutdown.

On my system, with beesd running against a filesystem mounted at
/mnt/games, systemd would attempt to unmount the filesystem while beesd
still held open file descriptors, resulting in:

umount: /mnt/games: target is busy.

Add Before=umount.target so beesd is stopped before systemd begins
deactivating mount units. Also add After=local-fs.target so beesd does
not start before local filesystems are ready, and TimeoutStopSec=300 to
allow sufficient time for the hash table to flush before escalating to
SIGKILL.
Change WantedBy from basic.target to multi-user.target so beesd starts only after the system is fully up.

Copilot AI review requested due to automatic review settings June 18, 2026 17:15

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the beesd@.service systemd unit template to improve shutdown ordering and reduce unmount failures (EBUSY) by ensuring beesd is stopped in time, and to allow longer graceful shutdown.

Changes:

  • Add ordering directives (After=local-fs.target, Before=umount.target) to better coordinate startup/shutdown with filesystem availability and unmounting.
  • Increase shutdown grace period via TimeoutStopSec=300.
  • Fix a typo in a security-hardening comment and change the unit’s WantedBy target.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scripts/beesd@.service.in
Description=Bees (%i)
Documentation=https://github.com/Zygo/bees
After=sysinit.target
# Prevents bees from still running while scanned FS is being unmounted
Comment thread scripts/beesd@.service.in

[Install]
WantedBy=basic.target
WantedBy=multi-user.target

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bees should not run in rescue mode anyway

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants