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

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 shows failure. First I was getting this:

systemd[304]: Failed to create / 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]: : Main process exited, code=exited, status=219/CGROUP
systemd[1]: : 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/

Now I can start 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.

Reset to default

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like