51 lines
2.3 KiB
Diff
51 lines
2.3 KiB
Diff
|
Based on d677d4df80e0ea1c66c691f50867fedd63c6770a Mon Sep 17 00:00:00 2001
|
||
|
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
||
|
Date: Thu, 16 Oct 2014 19:12:55 -0500
|
||
|
Subject: [PATCH] systemd: continue switch-root even if umount fails
|
||
|
|
||
|
Leaving the old root around seems better than aborting the
|
||
|
switch.
|
||
|
---
|
||
|
src/core/main.c | 2 +-
|
||
|
src/core/switch-root.c | 11 +++++------
|
||
|
2 files changed, 6 insertions(+), 7 deletions(-)
|
||
|
|
||
|
--- src/core/main.c
|
||
|
+++ src/core/main.c 2014-10-20 13:35:35.915837828 +0000
|
||
|
@@ -1848,7 +1848,7 @@ finish:
|
||
|
/* And switch root */
|
||
|
r = switch_root(switch_root_dir);
|
||
|
if (r < 0)
|
||
|
- log_error("Failed to switch root, ignoring: %s", strerror(-r));
|
||
|
+ log_error("Failed to switch root, trying to continue: %s", strerror(-r));
|
||
|
}
|
||
|
|
||
|
args_size = MAX(6, argc+1);
|
||
|
--- src/core/switch-root.c
|
||
|
+++ src/core/switch-root.c 2014-10-20 13:39:58.167121460 +0000
|
||
|
@@ -68,10 +68,9 @@ 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.
|
||
|
+ /* Work-around for kernel design: 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)
|
||
|
@@ -124,8 +123,8 @@ int switch_root(const char *new_root) {
|
||
|
* running off it we need to do this lazily. */
|
||
|
if (umount2("/mnt", MNT_DETACH) < 0) {
|
||
|
r = -errno;
|
||
|
- log_error("Failed to umount old root dir /mnt: %m");
|
||
|
- goto fail;
|
||
|
+ log_error("Failed to lazily umount old root dir /mnt, %s: %m",
|
||
|
+ errno == ENOENT ? "ignoring" : "leaving it around");
|
||
|
}
|
||
|
|
||
|
} else if (mount(new_root, "/", NULL, MS_MOVE, NULL) < 0) {
|