From 5ae4c36dfe392c2a0a729f2d5bc823759e83cf51 Mon Sep 17 00:00:00 2001 From: "Yann E. MORIN" Date: Sat, 15 Mar 2025 20:57:05 +0100 Subject: [PATCH] package/cgroupfs-v2-mount: new package Currently, the cgroupfs-mount package only mounts a cgroup v1 hierarchy, but v1 is considered legacy and obsolete, while v2 has been around for a while now, and is required by some packages (e.g. podman whines about v1). cgroupfs-mount has not had a release in almost 8 years now, and only the occasional commit since then and until more than 3 years ago. It's not going to evolve... Add a new package with a simple-enough sysv startup script, that mounts the cgroup v2 hierarchy filesystem. For systemd, there's nothing to do, as systemd handles the mount by itself. Since both cgroup v1 and v2 use the same mountpoint, we can't have both enabled at the same time, and thus we restrict the v2 to be hidden when v1 is enabled (quite a few packages select the v1; changing those would require that they be validated against v2 first...) Note that, due to limitations in Kconfig, cgroupfs-v2-mount will appear indented below cgroupfs-mount, because it has a (negative) dependency on it. This spurious indentation is unfortunate and annoying, but benign; fixing that would require breaking the dependency with a random Kconfig symbol, which we don't have, and which we decided not to introduce just for this one use-case (well, there's host-gnupg and host-gnupg2 that have the exact same issue, but meh...) Signed-off-by: Yann E. MORIN Cc: Fiona Klute Cc: Thomas Petazzoni Signed-off-by: Julien Olivain --- package/Config.in | 1 + package/cgroupfs-v2-mount/Config.in | 10 +++++ package/cgroupfs-v2-mount/S30cgroupfs2 | 44 +++++++++++++++++++ .../cgroupfs-v2-mount/cgroupfs-v2-mount.mk | 20 +++++++++ 4 files changed, 75 insertions(+) create mode 100644 package/cgroupfs-v2-mount/Config.in create mode 100644 package/cgroupfs-v2-mount/S30cgroupfs2 create mode 100644 package/cgroupfs-v2-mount/cgroupfs-v2-mount.mk diff --git a/package/Config.in b/package/Config.in index 0c9b5bb6cf..7d8540869d 100644 --- a/package/Config.in +++ b/package/Config.in @@ -2809,6 +2809,7 @@ menu "System tools" source "package/balena-engine/Config.in" source "package/bubblewrap/Config.in" source "package/cgroupfs-mount/Config.in" + source "package/cgroupfs-v2-mount/Config.in" source "package/circus/Config.in" source "package/conmon/Config.in" source "package/containerd/Config.in" diff --git a/package/cgroupfs-v2-mount/Config.in b/package/cgroupfs-v2-mount/Config.in new file mode 100644 index 0000000000..2dd2dbc089 --- /dev/null +++ b/package/cgroupfs-v2-mount/Config.in @@ -0,0 +1,10 @@ +config BR2_PACKAGE_CGROUPFS_V2_MOUNT + bool "cgroupfs-v2-mount" + depends on !BR2_INIT_SYSTEMD + depends on !BR2_PACKAGE_CGROUPFS_MOUNT + help + Mount the cgroup v2 hierarchy filesystem. + +comment "cgroupfs-v2-mount is incompatible with cgroupfs-mount" + depends on !BR2_INIT_SYSTEMD + depends on BR2_PACKAGE_CGROUPFS_MOUNT diff --git a/package/cgroupfs-v2-mount/S30cgroupfs2 b/package/cgroupfs-v2-mount/S30cgroupfs2 new file mode 100644 index 0000000000..42839ef921 --- /dev/null +++ b/package/cgroupfs-v2-mount/S30cgroupfs2 @@ -0,0 +1,44 @@ +#!/bin/sh + +DAEMON=cgroupfs2 + +start() { + printf 'Mounting %s: ' "${DAEMON}" + mkdir -p /sys/fs/cgroup + mount -t cgroup2 none /sys/fs/cgroup + status=$? + if [ "$status" -eq 0 ]; then + echo "OK" + else + echo "FAIL" + fi + return "$status" +} + +stop() { + printf 'Unmounting %s: ' "${DAEMON}" + umount /sys/fs/cgroup + status=$? + if [ "$status" -eq 0 ]; then + echo "OK" + else + echo "FAIL" + fi + return "$status" +} + +restart() { + stop + start +} + +case "$1" in + start|stop|restart) + "$1";; + reload) + # Restart, since there is no true "reload" feature. + restart;; + *) + echo "Usage: $0 {start|stop|restart|reload}" + exit 1 +esac diff --git a/package/cgroupfs-v2-mount/cgroupfs-v2-mount.mk b/package/cgroupfs-v2-mount/cgroupfs-v2-mount.mk new file mode 100644 index 0000000000..10e18d8d41 --- /dev/null +++ b/package/cgroupfs-v2-mount/cgroupfs-v2-mount.mk @@ -0,0 +1,20 @@ +################################################################################ +# +# cgroupfs-v2-mount +# +################################################################################ + +CGROUPFS_V2_MOUNT_VERSION = +CGROUPFS_V2_MOUNT_SITE = + +define CGROUPFS_V2_MOUNT_LINUX_CONFIG_FIXUPS + $(call KCONFIG_ENABLE_OPT,CONFIG_CGROUPS) +endef + +define CGROUPFS_V2_MOUNT_INSTALL_INIT_SYSV + $(INSTALL) -m 0755 -D \ + $(CGROUPFS_V2_MOUNT_PKGDIR)/S30cgroupfs2 \ + $(TARGET_DIR)/etc/init.d/S30cgroupfs2 +endef + +$(eval $(generic-package))