Skip to content

Instantly share code, notes, and snippets.

@mancubus77
Last active October 30, 2023 06:46
Show Gist options
  • Save mancubus77/0a56431fd50b957bf15af085dcaddf95 to your computer and use it in GitHub Desktop.
Save mancubus77/0a56431fd50b957bf15af085dcaddf95 to your computer and use it in GitHub Desktop.
Switch RHEL8 to cgroup v2

Solution 1

I was not able to run podman stats on RHEL8. The command returned:

Error: stats is not supported in rootless mode without cgroups v2

Solution based on this article -> https://sleeplessbeastie.eu/2021/09/10/how-to-enable-control-group-v2/

vi /etc/default/grub

and append systemd.unified_cgroup_hierarchy=1 to make it like

GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,115200n8 no_timer_check net.ifnames=0 crashkernel=auto systemd.unified_cgroup_hierarchy=1"

Rebuild grub config

grub2-mkconfig -o "$(readlink -e /etc/grub2.conf)"

Reboot system

init 6

Run it again

podman stats -a --no-stream
ID            NAME               CPU %       MEM USAGE / LIMIT  MEM %       NET IO      BLOCK IO    PIDS        CPU TIME      AVG CPU %
1a6dad44f8be  ansible_runner_66  4.39%       1.013GB / 17GB     5.96%       -- / --     -- / --     198         1m12.078589s  4.39%
276a8a3dba1a  ansible_runner_64  4.39%       1.013GB / 17GB     5.96%       -- / --     -- / --     198         1m12.078655s  4.39%
2be1402c870c  ansible_runner_70  4.39%       1.013GB / 17GB     5.96%       -- / --     -- / --     198         1m12.078821s  4.39%
a5ec1b29c8f5  ansible_runner_72  4.39%       1.013GB / 17GB     5.96%       -- / --     -- / --     198         1m12.079041s  4.39%
d691d440957f  ansible_runner_68  4.39%       1.013GB / 17GB     5.96%       -- / --     -- / --     198         1m12.079041s  4.39%

Happy dayz

Solution 2

Update Grub

sudo grubby --update-kernel=ALL --args='systemd.unified_cgroup_hierarchy'
sudo reboot

Tune cgroups

sudo mkdir /etc/systemd/system/user@.service.d
sudo cat > /etc/systemd/system/user@.service.d/delegate.conf<<EOF
[Service]
Delegate=cpu cpuset io memory pids
EOF
sudo systemctl daemon-reload
@mancubus77
Copy link
Author

hey @davemq
yes, apologies. Should be grub2.cfg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment