From 053f943dd15a3be6acd35dbe3626317ae4a77427 Mon Sep 17 00:00:00 2001 From: Dominique Martinet Date: Mon, 16 May 2022 12:21:50 +0900 Subject: [PATCH] init.d/root: add support for 'r?shared' fstab option on / containers on linux might require filesystems to be mounted with different propagation than the kernel default of 'private': by setting 'shared' in fstab for / options, one can now make the fs hierarchy shared. Note we use 'rshared' to make other existing mounts shared as well because the setting is contagious and it seemed more logical to behave as if the setting was set on / immediately (and thus inherited by other mounts) This fixes #525. --- init.d/root.in | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/init.d/root.in b/init.d/root.in index 0a059a2fb..df68c4364 100644 --- a/init.d/root.in +++ b/init.d/root.in @@ -20,7 +20,8 @@ depend() start() { - case ",$(fstabinfo -o /)," in + local root_opts=",$(fstabinfo -o /)," + case "$root_opts" in *,ro,*) ;; *) @@ -45,6 +46,21 @@ start() ;; esac + case "$root_opts" in + *,shared,*|*,rshared,*) + ebegin "Making root filesystem shared" + case "$RC_UNAME" in + Linux) + mount --make-rshared / + ;; + *) + ewarn "Ignoring 'shared' option for / on non-linux" + ;; + esac + eend $? "Root filesystem could not be mounted read/write" + ;; + esac + ebegin "Remounting filesystems" local mountpoint for mountpoint in $(fstabinfo); do