logind.conf 页面说明了编译的默认值和具有优先规则的多个配置文件。所有这些让我很难弄清楚当前的设置是什么。有没有办法打印 systemd-logind.service 当前已加载并正在使用的当前设置?
我环顾四周并没有发现任何东西,就我所见,人们总是对logind.conf提供的内容感到满意,这里是有趣的部分man logind.conf
:
HandlePowerKey=, HandleSuspendKey=, HandleHibernateKey=, HandleLidSwitch=, HandleLidSwitchDocked=
Controls how logind shall handle the system power and sleep keys and the lid switch to trigger actions such as system power-off or suspend. Can be one of "ignore", "poweroff", "reboot", "halt", "kexec", "suspend", "hibernate", "hybrid-sleep", and "lock". If "ignore", logind will never handle these keys. If
"lock", all running sessions will be screen-locked; otherwise, the specified action will be taken in the respective event. Only input devices with the
"power-switch" udev tag will be watched for key/lid switch events. HandlePowerKey= defaults to "poweroff". HandleSuspendKey= and HandleLidSwitch= default to
"suspend". HandleLidSwitchDocked= defaults to "ignore". HandleHibernateKey= defaults to "hibernate". If the system is inserted in a docking station, or if
more than one display is connected, the action specified by HandleLidSwitchDocked= occurs; otherwise the HandleLidSwitch= action occurs.
A different application may disable logind's handling of system power and sleep keys and the lid switch by taking a low-level inhibitor lock
("handle-power-key", "handle-suspend-key", "handle-hibernate-key", "handle-lid-switch"). This is most commonly used by graphical desktop environments to take
over suspend and hibernation handling, and to use their own configuration mechanisms. If a low-level inhibitor lock is taken, logind will not take any action
when that key or switch is triggered and the Handle*= settings are irrelevant.
然后我在这里重复有趣的部分:
控制 logind 如何处理系统电源和睡眠键以及盖子开关以触发系统断电或挂起等操作。可以是“ignore”、“poweroff”、“reboot”、“halt”、“kexec”、“suspend”、“hibernate”、“hybrid-sleep”和“lock”之一。
或者我的方式不对,这只是用于键盘键,而不是电源按钮?
无论如何,以前使用 acpi 很容易,只需替换 中的power_button脚本/usr/lib/acpid/
,是否有与 systemd 等效的东西?
注意(重要):如何使用 systemd 在键盘电源键上运行脚本?不是重复的,因为已被错误地标记为如何更改电源按钮关闭操作以在 systemd 下运行不回答我的问题的脚本的重复,因为这是从键盘管理电源键,而不是电源按钮:
正如@TooTea 所建议的那样,集成到机箱中的按钮可能确实被视为键盘按钮按下,无论如何,在检查后我没有这样的 /dev/input/by-path/platform-i8042-serio-0- event-kbd 文件来监视按下的键,那么它肯定不会回答我的问题。
逗留已启用
loginctl enable-linger
但是,用户服务在用户登录之前不会启动。再次注销时,服务仍处于活动状态。
当用户不在 /etc/passwd 文件中但通过 NIS 提供时,是否需要额外的东西才能使其工作?
该服务已正确添加到 中default.target
,因此这似乎与为什么我的 systemd 用户单元在启动时不启动?
现在,当我从 tty6 上的文本控制台切换到 tty3 上的 GNOME 时,我的系统正在执行磁盘 IO。1.4GB 的交换空间正在使用中。
在 tty6 上,我运行了,以检查它是否与“什么可能正在使用我的 6GB 交换空间?sudo lsof -p 1 | grep dev
”类似的问题。根据那里的背景信息,我希望 PID 1 具有打开的文件描述符. 但它没有!/dev/dri/...
当我从 tty3 运行命令时也是如此。但输出有所不同,因为它现在包含/dev/input/...
.
如果我切换回 tty3 并重试等,这些结果是可重复的。
注意这是我在上游 systemd 中接触过的代码,所以很可能是我的错 :-)。 查看 systemd git commit 消息src/login
,我找不到这种行为的明显故意改变。
我有一个用于 Fedora 27 和 Fedora 28 的虚拟机。他们当我启动它们并lsof
在串行控制台上运行时,Fedora 27 看起来不错。但是,在 Fedora 28 VM 上,如果我运行chvt 6
,则会出现同样的问题。
编辑:如果我将 SELinux 设置为“允许”(记录策略违规,但允许),这种明显的回归就会消失。我已经将它作为一个问题提交到 Fedora 中。 SELinux 干扰 systemd-logind 重启代码
- systemd-238-7.fc28.1.x86_64 (
应该包括“什么可能使用我的 6GB 交换空间? ”的修复。) - gnome-shell-3.28.1-3.fc28.x86_64
这不会发生在 Fedora 27 VM 上
- systemd-234-10.git5f8984e.fc27.x86_64
- gnome-shell-3.26.2-5.fc27.x86_64