无法禁用systemd serial-getty服务

loj*_*joe 17 tty archlinux gpio raspberry-pi systemd

在使用Arch Linux的Raspberry Pi上,有一个名为的服务活动serial-getty@AMA0.

单元文件是:/usr/lib/systemd/system/serial-getty@.service

作为root我可以调用

systemctl stop serial-getty@ttyAMA0
systemctl disable serial-getty@ttyAMA0
Run Code Online (Sandbox Code Playgroud)

但重启后,服务已启用并再次运行.

禁用后为什么启用服务?如何永久禁用它?

UPDATE

systemd使用发电机在/ usr/lib中/ systemd /系统发电机/是称为systemd-getty的发电机二进制.此二进制文件在系统启动时运行,并将符号链接serial-getty@ttyAMA0.service添加到/run/systemd/generator/getty.target.wants.

我终于找到了一个肮脏的解 我在/usr/lib/systemd/system/serial-getty@.service中注释掉了所有操作.无论如何,服务确实似乎已开始,但没有阻止ttyAMA0.

小智 35

停止再次启用服务的正确方法是使用:

systemctl mask serial-getty@ttyAMA0.service
Run Code Online (Sandbox Code Playgroud)

(在这种情况下使用ttyAMA0作为示例).这将为该服务的条目添加null的链接.