在我的 Ubuntu 18.04.1 系统上,systemd 的用户管理器无法启动。我认为这是我当前遇到的其他问题的根本原因。有什么想法可以摆脱这个吗?
系统版本
$ systemd --version
systemd 237
+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN2 +IDN -PCRE2 default-hierarchy=hybrid
Ubuntu 18.04.1 LTS 版本
$ uname -a
Linux example.com 4.15.0 #1 SMP Wed Jul 25 19:09:31 MSK 2018 x86_64 x86_64 x86_64 GNU/Linux
systemctl 单元状态
$ sudo systemctl status [email protected]
● [email protected] - User Manager for UID 1001
Loaded: loaded (/lib/systemd/system/[email protected]; static; vendor preset: enabled)
Drop-In: /lib/systemd/system/[email protected]
└─timeout.conf
Active: failed (Result: protocol) since Tue 2019-01-08 10:33:08 CET; 1min 42s ago
Process: 315 ExecStart=/lib/systemd/systemd --user (code=exited, status=1/FAILURE)
Main PID: 315 (code=exited, status=1/FAILURE)
Jan 08 10:33:08 example.com systemd[1]: Starting User Manager for UID 1001...
Jan 08 10:33:08 example.com systemd[315]: pam_unix(systemd-user:session): session opened for user mischa by (uid=0)
Jan 08 10:33:08 example.com systemd[1]: [email protected]: Failed with result 'protocol'.
Jan 08 10:33:08 example.com systemd[1]: Failed to start User Manager for UID 1001.
系统日志说
Jan 8 10:33:08 example.com systemd[1]: Starting User Manager for UID 1001...
Jan 8 10:33:08 example.com systemd[315]: Failed to create /user.slice/user-1001.slice/[email protected]/init.scope control group: Permission denied
Jan 8 10:33:08 example.com systemd[315]: Failed to allocate manager object: Permission denied
Jan 8 10:33:08 example.com systemd[1]: [email protected]: Failed with result 'protocol'.
Jan 8 10:33:08 example.com systemd[1]: Failed to start User Manager for UID 1001.
我的用户服务单位文件
$ cat /lib/systemd/system/[email protected]
# SPDX-License-Identifier: LGPL-2.1+
#
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
[Unit]
Description=User Manager for UID %i
After=systemd-user-sessions.service
[Service]
User=%i
PAMName=systemd-user
Type=notify
ExecStart=-/lib/systemd/systemd --user
Slice=user-%i.slice
KillMode=mixed
Delegate=pids cpu
TasksMax=infinity
TimeoutStopSec=120s
答案1
Ubuntu 的问题是缺少一个关键包,它是libpam-cgfs
答案2
升级 Ubuntu 后,我发生了这种情况...您可能需要检查以下目录链中的权限。
/sys/fs/cgroup/systemd/user.slice/user-1000.slice/
所以你需要确保其他具有完全读取和执行权限,因此您的用户可以创建该目录。对我来说,升级一定没有设置正确的权限/sys/fs/cgroup/systemd/ 所以我做了以下事情:
chmod o+rx /sys/fs/cgroup/systemd/
答案3
我相信这是具有统一 cgroup 层次结构的 systemd 版本 237 中的一个错误。
它也可以使用 systemd-run 重现:
解决方法是添加一个内核参数来禁用统一 cgroup 层次结构。
我使用这里的解决方法解决了我的问题:https://github.com/flathub/org.gimp.GIMP/issues/23#issuecomment-394911840
步骤是:
- 编辑/etc/default/grub,更改:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
到:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash systemd.legacy_systemd_cgroup_controller=1"
- sudo 更新 grub
- 重启
答案4
我使用后也出现过这种情况umount -a
,然后mount -a
。
一些目录变为只读;用 rw 重新安装它已解决;但我想我并没有涵盖所有内容。
...手动为每个活动服务创建文件夹结构
mkdir /sys/fs/cgroup/systemd/[slice]/service
其次是: ...
chmod o+rx /sys/fs/cgroup/systemd/ -R
systemctl daemon-reload
systemctl daemon-reexec
无需重新启动即可解决问题(必须避免它,因为我们正在运行服务)
重要的提醒:用过的chmod -R