aboutsummaryrefslogtreecommitdiff
path: root/init.d/sysfs.in
diff options
context:
space:
mode:
authorWilliam Hubbs <w.d.hubbs@gmail.com>2017-09-16 17:02:52 -0500
committerWilliam Hubbs <w.d.hubbs@gmail.com>2017-09-16 17:02:52 -0500
commit3fafd7a76e6adf15ec72a7ba5f44583eff8fab7a (patch)
treecad92873b1d6170cecb9cd8c8d7b959c25d69b81 /init.d/sysfs.in
parentcd5722aca50f0eaddde7ce04ee00da53c313ba7d (diff)
sysfs: fix cgroup hybrid mode
In hybrid mode, we should not try to mount cgroup2 if it is not available in the kernel. This fixes #164.
Diffstat (limited to 'init.d/sysfs.in')
-rw-r--r--init.d/sysfs.in25
1 files changed, 17 insertions, 8 deletions
diff --git a/init.d/sysfs.in b/init.d/sysfs.in
index 9f39fb57..23e8821c 100644
--- a/init.d/sysfs.in
+++ b/init.d/sysfs.in
@@ -150,6 +150,16 @@ cgroup1_controllers()
return 0
}
+cgroup2_base()
+{
+ local base
+ base="$(cgroup2_find_path)"
+ mkdir -p "${base}"
+ mount -t cgroup2 none -o "${sysfs_opts},nsdelegate" "${base}" 2> /dev/null ||
+ mount -t cgroup2 none -o "${sysfs_opts}" "${base}"
+ return 0
+}
+
cgroup2_controllers()
{
local active cgroup_path x y
@@ -169,13 +179,12 @@ cgroup2_controllers()
cgroups_hybrid()
{
- grep -qw cgroup /proc/filesystems &&
- grep -qw cgroup2 /proc/filesystems ||
- return 0
+ grep -qw cgroup /proc/filesystems || return 0
cgroup1_base
- mkdir /sys/fs/cgroup/unified
- mount -t cgroup2 none -o "${sysfs_opts},nsdelegate" /sys/fs/cgroup/unified
- cgroup2_controllers
+ if grep -qw cgroup2 /proc/filesystems; then
+ cgroup2_base
+ cgroup2_controllers
+ fi
cgroup1_controllers
return 0
}
@@ -190,8 +199,8 @@ cgroups_legacy()
cgroups_unified()
{
- grep -qw cgroup2 /proc/filesystems || return 0
- mount -t cgroup2 none -o "${sysfs_opts},nsdelegate" /sys/fs/cgroup
+ cgroup2_base
+ cgroup2_controllers
return 0
}