6

docker can only use cgroupv1, but fedora by default only use cgroupv2. How do I check if system is cgroupv1 compatible?

So far answer in this question can only determine if cgroupv2 is installed. But it cannot determine if unified_cgroup_hierarchy set to 0 or 1. Is there any uniform way to determine if system is cgroupv1 compatible regardless whether the cgroupv2 installed or not?

So far I use mount -l to check if there is cgroup2 on /sys/fs/cgroup. If there is, that means cgroupv2 only. Is this method universally applicable in all distros? So far I only tested on Fedora and ubuntu. If not, is there an universal way to determine this?

1 Answer 1

6

I would follow the approach used by systemd:

  • if /sys/fs/cgroup exists and is on a cgroup2 file system, the system is running with a full unified hierarchy;
  • if /sys/fs/cgroup exists and is on a tmpfs file system,
    • if either /sys/fs/cgroup/unified or /sys/fs/cgroup/systemd exist and are on cgroup2 file systems, the system is using a unified hierarchy for the systemd controller only;
    • if /sys/fs/cgroup/systemd exists and is on a cgroup file system (or, as a fallback, if it exists and isn’t on a cgroup2 file system), the system is using a legacy hierarchy.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.