Bug#572733: support for mounting other kernel filesystems

Mark Hindley mark at hindley.org.uk
Mon Sep 15 09:11:42 BST 2025


Control: tags -1 patch

I have a proposed generic framework to support mounting additional kernel
filesystems. I have added support for debugfs and cgroup2 but omitted cgroup.
None are enabled by default.

Comments welcome. Thanks.

Mark

diff --git a/debian/src/initscripts/etc/default/rcS b/debian/src/initscripts/etc/default/rcS
index 4778c85c..197959ba 100644
--- a/debian/src/initscripts/etc/default/rcS
+++ b/debian/src/initscripts/etc/default/rcS
@@ -31,3 +31,7 @@
 
 # Mount NFS filesystem asynchronously
 #ASYNCMOUNTNFS=yes
+
+# Additional (optional) kernel filesystems to mount. Options are debugfs,
+# and cgroup2.
+#EXTRAKERNELFS=
diff --git a/debian/src/initscripts/etc/init.d/mountkernfs.sh b/debian/src/initscripts/etc/init.d/mountkernfs.sh
index 353ef048..a0c901aa 100755
--- a/debian/src/initscripts/etc/init.d/mountkernfs.sh
+++ b/debian/src/initscripts/etc/init.d/mountkernfs.sh
@@ -60,6 +60,29 @@ mount_filesystems () {
 		# domount is a no-op if already mounted
 		domount "$MNTMODE" efivarfs "" $efivarsmnt none ""
 	fi
+
+	#
+	# Mount specific additional requests
+	#
+	for fs in $EXTRAKERNELFS ; do
+		case $fs in
+			debugfs)
+				if grep -wqs 'debugfs$' /proc/filesystems && [ -d /sys/kernel/debug ] ; then
+					domount "$MNTMODE" debugfs "" /sys/kernel/debug debugfs -onodev,noexec,nosuid
+				else
+					echo "Warning: ignoring unavailable debugfs" >&2
+				fi
+				;;
+			cgroup2)
+			    	if grep -wqs 'cgroup2$' /proc/filesystems && [ -e /proc/cgroups ] ; then
+					domount "$MNTMOUDE" cgroup2 "" /sys/fs/cgroup cgroup2 -onodev,noexec,nosuid
+				else
+					echo "Warning: ignoring unavailable cgroup2" >&2
+				fi
+				;;
+			*) echo "Warning: ignoring unsupported kernel filesystem $fs" >&2 ;;
+		esac
+	done
 }
 
 case "$1" in
diff --git a/debian/src/initscripts/man/rcS.5 b/debian/src/initscripts/man/rcS.5
index b9d384e1..f1e6961d 100644
--- a/debian/src/initscripts/man/rcS.5
+++ b/debian/src/initscripts/man/rcS.5
@@ -91,6 +91,10 @@ marked 'auto'
 .RB ( NOT " 'allow\-hotplug')"
 in \fB/etc/network/interfaces\fP.
 
+.IP \fBEXTRAKERNELFS\fP
+A space separated list of additional optional kernel filesystems to mount. The
+current available options are \fBdebugfs\fP and \fBcgroup2\fP.
+
 .SH NOTE
 The \fBEDITMOTD\fP, \fBRAMRUN\fP, \fBCONCURRENCY\fP and \fBUTC\fP variables are
 no longer used. To inhibit concurrent boot, use



More information about the Debian-init-diversity mailing list