Skip to content

Commit

Permalink
init.d/root: add support for 'r?shared' fstab option on /
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
martinetd committed Jul 28, 2024
1 parent ba6de6d commit 053f943
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion init.d/root.in
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ depend()

start()
{
case ",$(fstabinfo -o /)," in
local root_opts=",$(fstabinfo -o /),"
case "$root_opts" in
*,ro,*)
;;
*)
Expand All @@ -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
Expand Down

0 comments on commit 053f943

Please sign in to comment.