summaryrefslogtreecommitdiff
path: root/src/shutdown
diff options
context:
space:
mode:
authorValentin David <valentin.david@canonical.com>2023-01-09 20:21:16 +0100
committerValentin David <valentin.david@canonical.com>2023-01-11 15:30:44 +0100
commit2cc0cd4371b9a3717380c858fc7e1b39cc632d08 (patch)
tree3a21407272cc792cf2cd93c94b1e0f7f322fbc11 /src/shutdown
parent6dc68a00cfc816678fd713b12ae2a4cf2ae6da85 (diff)
downloadsystemd-2cc0cd4371b9a3717380c858fc7e1b39cc632d08.tar.gz
shutdown: Make all mounts private
When systemd-shutdown is run, shared propagation is not needed anymore. Making mounts private allow to move mount points. This is needed to untangle cyclic mounts.
Diffstat (limited to 'src/shutdown')
-rw-r--r--src/shutdown/shutdown.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/shutdown/shutdown.c b/src/shutdown/shutdown.c
index d0120bb85d..42111d2772 100644
--- a/src/shutdown/shutdown.c
+++ b/src/shutdown/shutdown.c
@@ -400,6 +400,11 @@ int main(int argc, char *argv[]) {
/* Lock us into memory */
(void) mlockall(MCL_CURRENT|MCL_FUTURE);
+ /* We need to make mounts private so that we can MS_MOVE in unmount_all(). Kernel does not allow
+ * MS_MOVE when parent mountpoints have shared propagation. */
+ if (mount(NULL, "/", NULL, MS_REC|MS_PRIVATE, NULL) < 0)
+ log_warning_errno(errno, "Failed to make mounts private, ignoring: %m");
+
/* Synchronize everything that is not written to disk yet at this point already. This is a good idea so that
* slow IO is processed here already and the final process killing spree is not impacted by processes
* desperately trying to sync IO to disk within their timeout. Do not remove this sync, data corruption will