how do I check if system is using cgroupv1?

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?

Asked By: Wang


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.
Answered By: Stephen Kitt

if /sys/fs/cgroup/unified is on cgroup2 and /sys/fs/cgroup/systemd/ is on cgroup , both exists with this configuration on my linux.
Then which is currently being used ?

Answered By: Dhananjay Joshi

"If /sys/fs/cgroup/cgroup.controllers is present on your system, you are using v2, otherwise you are using v1".


Answered By: cactuschibre
Categories: Answers Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.