错误信息

错误信息

为什么我会收到依赖错误?我只指定之前运行什么,并没有说明之后运行什么。然而,存在依赖循环。

我尝试向 systemd 添加服务,但现在出现排序错误。

错误信息

摘自/var/log/boot.log

[ SKIP ] Ordering cycle found, skipping local-fs-pre.target
[ SKIP ] Ordering cycle found, skipping systemd-ask-password-plymouth.path
[ SKIP ] Ordering cycle found, skipping paths.target
[ SKIP ] Ordering cycle found, skipping cryptsetup.target
[ SKIP ] Ordering cycle found, skipping local-fs.target
[ SKIP ] Ordering cycle found, skipping local-fs-pre.target
[ SKIP ] Ordering cycle found, skipping systemd-ask-password-plymouth.path
[ SKIP ] Ordering cycle found, skipping cryptsetup.target
[ SKIP ] Ordering cycle found, skipping systemd-pcrphase-sysinit.service
[ SKIP ] Ordering cycle found, skipping local-fs.target
[ SKIP ] Ordering cycle found, skipping local-fs-pre.target
[ SKIP ] Ordering cycle found, skipping plymouth-start.service
[ SKIP ] Ordering cycle found, skipping cryptsetup.target
[ SKIP ] Ordering cycle found, skipping local-fs.target
[ SKIP ] Ordering cycle found, skipping local-fs-pre.target
[ SKIP ] Ordering cycle found, skipping systemd-ask-password-plymouth.path
[ SKIP ] Ordering cycle found, skipping cryptsetup.target
[  OK  ] Finished plymouth-read-write.service - Tell Plymouth To Write Out Runtime Data.
[  OK  ] Finished systemd-tmpfiles-setup.service - Create Volatile Files and Directories.
         Starting systemd-timesyncd.service - Network Time Synchronization...
         Starting systemd-update-utmp.service - Record System Boot/Shutdown in UTMP...
[ SKIP ] Ordering cycle found, skipping systemd-ask-password-plymouth.path
[ SKIP ] Ordering cycle found, skipping cryptsetup.target

服务文件

cat ./remove-bad-yoga-keyboard-device.service

[Unit]
Description=disable the internal keyboard
Before=keyboard-setup.service 
Before=console-setup.service 
Before=systemd-user-sessions.service

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/local/remove-bad-yoga-keyboard-device
WorkingDirectory=/local
StandardOutput=inherit
StandardError=inherit
User=root

[Install]
WantedBy=multi-user.target

安装程序

cat setup-disable-yoga-keyboard

#!/bin/bash
cwd="$(pwd)"
cd "$(dirname "$(realpath "$0")")"
this_dir="$(pwd)"

mkdir -p /local
cd /local
cp -t . "${this_dir}"/remove-bad-yoga-keyboard-device

cd /etc/systemd/system
cp -t . "${this_dir}"/remove-bad-yoga-keyboard-device.service

systemctl daemon-reload
systemctl enable remove-bad-yoga-keyboard-device.service

有些玩与 systemd-analyze显示出冲突shutdown.target。然而,当我分析这个目标时,发现它与一切都相冲突。我的猜测是关闭是特殊的,分析仪不理解它。这shutdown.target不是问题所在。这给我留下了一个问题,什么是。

经过更多的尝试后,我删除了规则Before=keyboard-setup.servicesystemd-analyze verify通过了它,并且它启动时没有错误。

但为什么我会收到依赖错误?我只指定之前运行什么,并没有说明之后运行什么。然而,存在依赖循环。


操作系统:Debian GNU/Linux 12 (bookworm) /local是根分区上的一个目录

答案1

因为它不包含设置DefaultDependencies=no,所以您remove-bad-yoga-keyboard-device.service将自动获得一些额外的依赖项:

Requires=sysinit.target
After=sysinit.target
After=basic.target
Conflicts=shutdown.target
Before=shutdown.target

请参阅以下段落默认依赖项man 5 systemd.service

键盘在系统启动的早期就被初始化,因为类似的事情cryptsetup.service可能需要输入密码。由于您已经指定您的服务应该运行Before=keyboard-setup.service,因此它确实被放置得很早。但是自动生成的默认依赖项要求它After同时放置sysinit.targetbasic.target,从而导致循环。

因此,您应该研究 中的流程图man 7 bootup,并且每当您编写将放置在之前任何位置的服务时basic.target请记住添加DefaultDependencies=no任何此类服务。

相关内容