Score:1

systemd --user fails to start while complaining about permission in ubuntu server 20.04 inside openvz 7

us flag

Info about the system.

# systemctl --version
systemd 245 (245.4-4ubuntu3.13)
+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD +IDN2 -IDN +PCRE2 default-hierarchy=hybrid
# uname -srvmpio
Linux 5.4.0 #1 SMP Mon Mar 16 15:39:59 MSK 2020 x86_64 x86_64 x86_64 GNU/Linux
# cat /proc/cmdline
quiet
# loginctl enable-linger USERNAME

Problem

System --user daemon fails to start. systemctl status [email protected] shows failure. First I was getting this:

systemd[304]: Failed to create /user.slice/user-1001.slice/[email protected]/init.scope control group: Permission denied
systemd[304]: Failed to allocate manager object: Permission denied

After googling a bit I installed libpam-cgfs via apt. With it,

systemd[1]: [email protected]: Main process exited, code=exited, status=219/CGROUP
systemd[1]: [email protected]: Failed with result 'exit-code'.
systemd[1]: Failed to start User Manager for UID 1001.

Various threads in google suggests a manual workaround, setting more open permission in /sys/fs/cgroup/systemd/

So I ran these.

chmod -R o+rx /sys/fs/cgroup/systemd/

This didn't work, So it added write permission at user.slice

chmod -R o+rwx /sys/fs/cgroup/systemd/user.slice/

Now I can start [email protected] and it starts successfully.

One of the possible diagnosis I got that if cgroups are in unified mode,this problem occurs, suggestion is to put a flag in GRUB to set cgroups to legacy mode. But obviously those doesn't apply to my case as I'm inside a openvz container and there's no grub. My cgroups seems to be running in hybrid mode.

What can I do to fix the permission or anything else to fix this? I don't think running +w is a good thing every time system boots.

Edit: Relevant threads I found googling.

  1. https://unix.stackexchange.com/questions/493187/systemd-under-ubuntu-18-04-1-fails-with-failed-to-create-user-slice-serv
  2. https://github.com/systemd/systemd/issues/3388
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.