I’m sorry if this question is not about LXC itself but I couldn’t find the solution anywhere else.
I’m trying to monitor resource usage of LXC containers by running systemd-cgtop on Ubuntu 20.04 host.
CPU and Memory columns are fine but both Input and Output columns always have “-” in them even under a heavy disk load.
I tried changing these systemd settings but it didn’t help (tried both yes and no):
Block accounting on Linux has been pretty useless for a little while.
That’s because only a single I/O scheduler (CFQ) ever implemented it properly and most Linux distributions have moved away from it.
These days, most systems use SCSI multi-queue (mq) and NVME drives, which uses the noop scheduler. As the name implies, that scheduler does nothing and just queues all requests straight in hardware. This effectively prevents us from pulling any useful statistics or apply any I/O limits.
I added systemd.unified_cgroup_hierarchy=1 to the kernel’s command line and now systemd-cgtop shows Input/Output. But I ran into another problem, my containers didn’t start:
$ lxc-start ansible -F
Failed to mount cgroup at /sys/fs/cgroup/systemd: Operation not permitted
[!!!!!!] Failed to mount API filesystems.
Exiting PID 1...
Ubuntu 20.04 is indeed a cgroup1 distro by default. Ubuntu 22.04 comes with cgroup2 instead.
Your container failing to start out of the box is most likely because it’s running one of those distros that won’t handle cgroup2 properly out of the box. We mostly see this on CentOS 7 or Ubuntu 16.04, newer distros tend to just go with whatever is enabled on the system.