Today, I tried to enable cgroup v2 on my Rocky Linux 9 machine. I’ve heard that cgroup v2 is the default in version 9.0, so I thought it would be easy. It turns out to be a bit tricky, but I finally figured it out.
First, I checked if my system supported cgroup v2 by looking at the output of some command. If it said “cgroup2fs”, that means v2 was supported, otherwise, it would be v1. And mine showed “cgroup2fs”.
Then, I learned that cgroup is something that limits resources for applications, like memory or CPU usage. I found out that most modern Linux systems now use cgroup v2 instead of the older v1. And also i knew that cgroup v2 uses a single hierarchy model.
I was using Podman on Rocky Linux and ran into an error. When I checked the Podman info, it showed me some details including cgroup tags. It seems like cgroup is related to containers, and things like Docker or Podman.
So I thought, how can I actually turn on the cgroup v2 CPU controller? Turns out, I just needed to enable some controllers that I wanted to use, like the CPU controller. Resources are distributed from top to bottom in the cgroup hierarchy. I tried to set some limits on CPU usage using the setting in different directories, but it didn’t seem to work unless I set it at the lowest level of the cgroup configuration.
Finally, I found out that I could add “cgroup_no_v1=all” to some configuration to fully switch to cgroup v2. After making these changes and rebooting, my system was fully using cgroup v2. I felt accomplished having learned all this about cgroups and getting it working on my machine.
- Checked cgroup version support
- Learned about cgroup and its purpose
- Encountered issues with Podman
- Explored enabling controllers
- Tried setting limits with “*”
- Finally enabled cgroup v2 with “cgroup_no_v1=all”
It was quite a journey, but now my Rocky Linux 9 is running with cgroup v2 enabled, and I have a better understanding of how resource control works in Linux.