Systemd、重启和权限

Systemd、重启和权限

由于我是新手,无法发表评论不过,我会提出一个新问题...

问题是关于Systemd/Systemctl不允许关机或重启。

我想要评论的答案是,您只需输入:

systemctl enable poweroff.target

来解决这个问题。但是,至少在我的系统上,这不起作用。

正如您在下面的尝试中看到的,我已以 root 身份登录(sudo su),但甚至不允许 root 重新启动:

root@Vidar:/home/bokkie# systemctl enable poweroff.target
root@Vidar:/home/bokkie# shutdown -r now
Failed to start reboot.target: Transaction is destructive.
See system logs and 'systemctl status reboot.target' for details.
root@Vidar:/home/bokkie# 

我似乎必须重新启动的唯一选项是进行硬关机(长按电源按钮)。

我可以替换 systemd 吗?或者以某种方式让 systemctl 允许关闭/重启?如果可以,怎么做?

答案1

在 Ubuntu 16.04 中

systemctl enable poweroff.target

创建一个符号链接,/etc/systemd/system/ctrl-alt-del.target将按 ctrl+alt+delete 的行为更改为关机,而不是重启

要重新启动,systemctl您应该运行

systemctl isolate reboot.target 

如果你确实需要重启,但似乎什么都不起作用,还有另一种方法。这与按住电源关闭按钮非常相似,但除非是最后的手段,否则我不建议使用这种方法。你可以运行:

echo b > /proc/sysrq-trigger

这将立即重新启动而不执行任何操作(包括卸载文件系统) - 这可能会导致文件系统损坏等。更多详细信息请参见这里这里

也可能有用。

答案2

它起作用了,在我输入了访问加密主目录的密码之后......在再次尝试之前,我查看了系统日志,发现:

Sep 25 14:57:14 Vidar systemd[1]: message repeated 3 times: [ Requested transaction contradicts existing jobs: Transaction is destructive.]
Sep 25 14:57:22 Vidar systemd-cryptsetup[25670]: Loading of cryptographic parameters failed: Invalid argument
Sep 25 14:57:22 Vidar systemd-cryptsetup[25670]: Failed to activate: Invalid argument
Sep 25 14:57:23 Vidar systemd[1]: [email protected]: Main process exited, code=exited, status=1/FAILURE
Sep 25 14:57:23 Vidar systemd[1]: Failed to start Cryptography Setup for cryptswap1.
Sep 25 14:57:23 Vidar systemd[1]: Dependency failed for dev-mapper-cryptswap1.device.
Sep 25 14:57:23 Vidar systemd[1]: Dependency failed for /dev/mapper/cryptswap1.
Sep 25 14:57:23 Vidar systemd[1]: dev-mapper-cryptswap1.swap: Job dev-mapper-cryptswap1.swap/start failed with result 'dependency'.
Sep 25 14:57:23 Vidar systemd[1]: dev-mapper-cryptswap1.device: Job dev-mapper-cryptswap1.device/start failed with result 'dependency'.
Sep 25 14:57:23 Vidar systemd[1]: [email protected]: Unit entered failed state.
Sep 25 14:57:23 Vidar systemd[1]: [email protected]: Failed with result 'exit-code'.

我将结束这个问题。

相关内容