I recently upgrade my system from Ubuntu 20.04 to 22.04. Then my (unprivileged) LXC container stopped working. I also tried downloading new ones, which didn’t work eiter.
Things that I have checked/tried
privileged containers worked well
I did not see any messages about AppArmor in /var/log/syslog
I downloaded and tried to start new containers of ubuntu and archlinux, neither worked.
I tried another user to run containers, didn’t work.
Modifed init command to /bin/bash, didn’t work.
Things I did not try
Reboot host with cgroupv1/hybrid, I just try to make it work with v2
Output of lxc-checkconfig
LXC version 5.0.0~git2209-g5a7b9ce67
Kernel configuration not found at /proc/config.gz; searching...
Kernel configuration found at /boot/config-5.15.0-46-generic
--- Namespaces ---
Namespaces: enabled
Utsname namespace: enabled
Ipc namespace: enabled
Pid namespace: enabled
User namespace: enabled
Network namespace: enabled
--- Control groups ---
Cgroups: enabled
Cgroup namespace: enabled
Cgroup v1 mount points:
Cgroup v2 mount points:
/sys/fs/cgroup
Cgroup v1 systemd controller: missing
Cgroup v1 freezer controller: missing
Cgroup ns_cgroup: required
Cgroup device: enabled
Cgroup sched: enabled
Cgroup cpu account: enabled
Cgroup memory controller: enabled
Cgroup cpuset: enabled
--- Misc ---
Veth pair device: enabled, loaded
Macvlan: enabled, not loaded
Vlan: enabled, not loaded
Bridges: enabled, loaded
Advanced netfilter: enabled, loaded
CONFIG_IP_NF_TARGET_MASQUERADE: enabled, not loaded
CONFIG_IP6_NF_TARGET_MASQUERADE: enabled, not loaded
CONFIG_NETFILTER_XT_TARGET_CHECKSUM: enabled, not loaded
CONFIG_NETFILTER_XT_MATCH_COMMENT: enabled, not loaded
FUSE (for use with lxcfs): enabled, not loaded
--- Checkpoint/Restore ---
checkpoint restore: enabled
CONFIG_FHANDLE: enabled
CONFIG_EVENTFD: enabled
CONFIG_EPOLL: enabled
CONFIG_UNIX_DIAG: enabled
CONFIG_INET_DIAG: enabled
CONFIG_PACKET_DIAG: enabled
CONFIG_NETLINK_DIAG: enabled
File capabilities:
Note : Before booting a new kernel, you can check its configuration
usage : CONFIG=/path/to/config /usr/bin/lxc-checkconfig
If I understood correctly, there must be something wrong before the container, as the init command does not make any effect.
I Googled the error message __cgfsng_delegate_controllers: 2953 Device or resource busy - Could not enable "+memory +pids" controllers in the unified cgroup 8, but didn’t find anything particular helpful.
That post does look similar, I also upgraded Ubuntu from 20.04 to 22.04.
I reckon as well going back to cgroupv1/hybrid might work, but I want it to make it work in v2. I have seen this workaround in different places, but I have not seen an explanation on “what’s wrong with the cgroup v2 setup”.
Sorry I updated my previous message several times.
Now I think it is not a false alarm. I was confused because I messed up with PATH.
I tried running my local build with and without systemd-run, no matter the case, I saw the following in the log.
TRACE cgfsng - ../src/lxc/cgroups/cgfsng.c:__cgfsng_delegate_controllers:3336 - Enabled "+memory +pids" controllers in the unified cgroup 11
Maybe related: I’ve been using sudo machinectl shell my-dev-user@ to enter a dev shell, then I’d run my local build in that shell, with or without systemd-run
In the shell I tried mount -t cgroup2 none somewhere, but I always got error “cannot mount … read only”. I’m not sure about the root cause though.
As for the hack, I found this bug and this PR relevant. Both are for runc.
I followed the same idea and apply the bind-mount in __cgroupfs_mount, which worked.
I’m not sure whether this would be a proper fix though.
Also a note, systemd automatically creates directories in /sys/fs/cgroup, I also needed to grant permissions to the container root, otherwise bind-mount would fail.
With “umask” I was able to find a couple of existing issues. E.g. #2277 and #3100.
Apparently this also happened for cgroup v1, and it was “fixed” in pam-cgfs.
Now that cgroup v2 is handled by systemd (if I understood correctly), I wonder if this is a bug of LXC, or systemd, or maybe not a bug in the first place?