summaryrefslogtreecommitdiff
path: root/src/core/switch-root.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-08-12 01:29:41 +0200
committerLennart Poettering <lennart@poettering.net>2012-08-12 01:31:03 +0200
commitf47fc35555565c4b161c2e44b357b4dbaf3a997d (patch)
treea1026031cc5df2e3801772e59e0440a07639b2b4 /src/core/switch-root.c
parentdbf61afb29e016fe1b4ac48312a782df1d60a3e6 (diff)
switch-root: remount to MS_PRIVATE
The kernel does not allow switching roots if things are mounted MS_SHARED. As a work-around, remount things MS_PRIVATE before switching roots. This should be fixed in the kernel for good. https://bugzilla.redhat.com/show_bug.cgi?id=847418
Diffstat (limited to 'src/core/switch-root.c')
-rw-r--r--src/core/switch-root.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/core/switch-root.c b/src/core/switch-root.c
index 9832a520e4..efc7d345e1 100644
--- a/src/core/switch-root.c
+++ b/src/core/switch-root.c
@@ -56,6 +56,15 @@ int switch_root(const char *new_root) {
goto fail;
}
+ /* Work-around for a kernel bug: for some reason the kernel
+ * refuses switching root if any file systems are mounted
+ * MS_SHARED. Hence remount them MS_PRIVATE here as a
+ * work-around.
+ *
+ * https://bugzilla.redhat.com/show_bug.cgi?id=847418 */
+ if (mount(NULL, "/", NULL, MS_REC|MS_PRIVATE, NULL) < 0)
+ log_warning("Failed to make \"/\" private mount: %m");
+
NULSTR_FOREACH(i, move_mounts) {
char new_mount[PATH_MAX];
struct stat sb;