summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/shutdown.c17
-rw-r--r--src/core/switch-root.c9
2 files changed, 17 insertions, 9 deletions
diff --git a/src/core/shutdown.c b/src/core/shutdown.c
index 0b7cbd8d34..c3a4c390be 100644
--- a/src/core/shutdown.c
+++ b/src/core/shutdown.c
@@ -104,15 +104,14 @@ static int pivot_to_new_root(void) {
return -errno;
}
- /*
- In case some evil process made "/" MS_SHARED
- It works for pivot_root, but the ref count for the root device
- is not decreasing :-/
- */
- if (mount(NULL, "/", NULL, MS_REC|MS_PRIVATE, NULL) < 0) {
- log_error("Failed to make \"/\" private mount %m");
- return -errno;
- }
+ /* 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");
if (pivot_root(".", "oldroot") < 0) {
log_error("pivot failed: %m");
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;