Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add option to make mountpoints shared #525

Closed
martinetd opened this issue May 13, 2022 · 4 comments · Fixed by #526
Closed

add option to make mountpoints shared #525

martinetd opened this issue May 13, 2022 · 4 comments · Fixed by #526

Comments

@martinetd
Copy link
Contributor

martinetd commented May 13, 2022

Hello,

I'd be interested in making all mountpoints shared (for example by allowing to run mount --make-rshared / in init.d/root) in alpine.
The implementation itself isn't difficult, busybox mount does support --make-rshared despite not being listed in the help so it's just a matter of adding a setting (EDIT: original idea was to look for 'shared' in fstabinfo -o /) and doing it -- I'll be happy to open a PR if there is some approval first.

I was told to ask here in the alpine ticket: https://gitlab.alpinelinux.org/alpine/tsc/-/issues/42

(rationale below copied from that link verbatim)
-=-
The rationale for this is that I selfishly need to have some mountpoints mounted as shared for some container usages (when alpine is the host OS), in order to backpropagate mounts made by a privileged container in a volume marked as 'shared'.
In my case the volumes shouldn't be made directly off /, so just marking the FS where volumes should be as shared is probably going to be enough but it's not something I have direct control of so I'd be more comfortable with / marked shared as systemd has been doing (not a great argument admittedly... But it's what users are used to)

FWIW, it looks like podman 4 in rootless mode also seems to depend on it: containers/podman#12721 and aports#13541 (closed) (the hang might not be related but it illustrates the warning message being shown), so we might get other requests at this point.
-=-

Thank you!

@ncopa
Copy link
Contributor

ncopa commented May 13, 2022

It would be nice to have this configurable, one way or the other, and I think /etc/init.d/root would be the proper place.

@williamh
Copy link
Contributor

I read the Alpine issue, and I'm open to this, but I have a question.
It looks like this can be done by adding rshared to the mount options for / in fstab.
What are the advantages or disadvantages of modifying init.d/root vs fstab?
Thanks a lot for explaining this.

@martinetd
Copy link
Contributor Author

Can it be done with mount options in fstab? I couldn't get it to work. mount options shared or private work for new mounts, but as far as I can see:

  • mount -o remount,(r)shared / doesn't work, we have to use mount --make-(r)shared / specific options
  • fstab options are not read by the kernel when mounting /, initrd might? but I'm not using initrd on the systems I'm targetting here, I don't think we should rely on it
  • (rootflags= kernel option would probably work, though; but conceptually I'd prefer to use fstab)

My intention was to add handling in init.d/root that would just call fstabinfo -o / and do the mount --make-rshared / there, like we do for mount -o remount,rw if ro isn't present.

Is there any preference to which way the default should go? all mount implementations might not support make-rshared (I'm not sure it'd make sense on BSDs, not sure how mount propagation work there this all looks very linux-y), so default of not doing anything and adding mount --make-rshared if shared is present is probably the best?

martinetd added a commit to martinetd/openrc that referenced this issue May 16, 2022
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 OpenRC#525.
@vampywiz17
Copy link

@vapier

It will merge it to the near future? I use Alpine linux to a Docker host and this settings that would be good to docker volumes...

martinetd added a commit to martinetd/openrc that referenced this issue Jul 27, 2024
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 OpenRC#525.
martinetd added a commit to martinetd/openrc that referenced this issue Jul 28, 2024
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 OpenRC#525.
navi-desu pushed a commit that referenced this issue Jul 28, 2024
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.
navi-desu pushed a commit to navi-desu/openrc that referenced this issue Sep 9, 2024
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 OpenRC#525.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants