大网数据广告活动
服务器运维问答

systemd unit on separate partition fails to load on reboot

· 52CE 我爱测

I have a .service on a separate partition which is linked with "systemctl enable" but does not automatically start on boot. Running "systemctl status" claims "failed to load" and it works if I run systemctl daemon-reload . My gue…

问题原文

原帖链接 · cdleonard · CC BY-SA 4.0

I have a .service on a separate partition which is linked with "systemctl enable" but does not automatically start on boot. Running "systemctl status" claims "failed to load" and it works if I run systemctl daemon-reload.

My guess is that this happens because it's on a separate partition and I was able to workaround this by doing "cp -t /etc/systemd/system" explicitly.

This seems like something that should "just work", what am I missing?

已采纳解答

原帖链接 · filbranden · CC BY-SA 4.0

Yes, this is expected and it's documented in the systemctl(1) man page, under the enable command:

The file system where the linked unit files are located must be accessible when systemd is started (e.g. anything underneath /home or /var is not allowed, unless those directories are located on the root file system).

The reason for the limitation is that systemd scans all units and assembles a transaction at startup. Mounting other filesystems is done through units, so units in other filesystems will not be available until the transaction is already in progress. systemd will not rescan the units and recalculate the transaction after those filesystems are mounted.

Copying the units into the root filesystem is an appropriate workaround, as you already found out.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2020-03-12)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。