How to use disable cgroupv2

October 27 2024

cgroupsv2 might not be compatible with some software packages so this tutorial helps disable that

What are cgroups?

Cgroups or control groups allow you to allocate resources like CPU or memory to a group of tasks. For more in depth about cgroups read this

Why would I want to move to cgroupv1

In my case, I wanted to run judge0 on Amazon Linux 2023 but saw this issue

Disabling on Ubuntu

sudo nano /etc/default/grub
# edit this line, and save:
GRUB_CMDLINE_LINUX="systemd.unified_cgroup_hierarchy=0"
sudo update-grub
sudo reboot

Disabling on Amazon Linux

Instead of manually editing the config, I used an EC2 launch template that would create my EC2 instances with cgroupsv1 enabled by default

Steps:

  • Navigate to EC2 -> Launch Templates
  • Pick an Amazon Linux AMI of your choice
  • In Advanced details -> User Data paste this in
#!/bin/bash
grubby --update-kernel=ALL --args="systemd.unified_cgroup_hierarchy=0"

Go back home.