summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2023-04-28 18:35:31 +0200
committerLennart Poettering <lennart@poettering.net>2023-05-03 17:55:55 +0200
commitf2c1d491a539035d6cc1fa53a7cef0cbc8d52902 (patch)
treeada41e8437d437c7b3c4e3fe949dbbd48d6b9a22 /src/core
parentc4039ceb9e063d72f6afb7bc05d583de55966718 (diff)
downloadsystemd-f2c1d491a539035d6cc1fa53a7cef0cbc8d52902.tar.gz
switch-root: don't require /mnt/ when switching root into host OS
So far, we invoked pivot_root() specifying /mnt/ as second argument, which then unmounted right-after. We'd create /mnt/ if needed. This sucks, because it means /mnt/ must strictly be pre-created on immutable images. Remove this limitation, by using pivot_root() with "." as source and target, which will result in two stacked mounts afterwards: the new one underneath, the old one ontop. We can then simply unmount the top one, and have what we want without needing any extra /mnt/ dir. Since we don't need /mnt/ anymore we can get rid of the extra unmount_old_root parameter and simply specify it as NULL if we don't want the old mount to stick around.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/main.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/core/main.c b/src/core/main.c
index 932ea64e45..af88fe34bb 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -1797,7 +1797,7 @@ static int do_reexecute(
broadcast_signal(SIGTERM, false, true, arg_default_timeout_stop_usec);
/* And switch root with MS_MOVE, because we remove the old directory afterwards and detach it. */
- r = switch_root(switch_root_dir, "/mnt", true, MS_MOVE);
+ r = switch_root(switch_root_dir, /* old_root_after= */ NULL, MS_MOVE);
if (r < 0)
log_error_errno(r, "Failed to switch root, trying to continue: %m");
}