summaryrefslogtreecommitdiffstats
path: root/src/shutdown
diff options
context:
space:
mode:
authorJan Janssen <medhefgo@web.de>2022-05-18 08:12:31 +0200
committerJan Janssen <medhefgo@web.de>2022-06-09 17:02:50 +0200
commitdf48b430a4a85f923eaecb3fadf9c514692d2082 (patch)
treee52a5486a22e2c861dbb099dd2ca01edd1ce6fbb /src/shutdown
parentshutdown: Log processes that block umount (diff)
downloadsystemd-df48b430a4a85f923eaecb3fadf9c514692d2082.tar.xz
systemd-df48b430a4a85f923eaecb3fadf9c514692d2082.zip
shutdown: Lazy unmount /oldroot/{dev,proc,sys}
These should not prevent us from cleaning up the remainders of /oldroot if something in the kernel is blocking these from being unmounted.
Diffstat (limited to 'src/shutdown')
-rw-r--r--src/shutdown/umount.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/shutdown/umount.c b/src/shutdown/umount.c
index 243a1f80ef..1e691379a4 100644
--- a/src/shutdown/umount.c
+++ b/src/shutdown/umount.c
@@ -648,6 +648,17 @@ static int umount_with_timeout(MountPoint *m, bool last_try) {
if (r == -EBUSY && last_try)
log_umount_blockers(m->path);
+
+ /* If API filesystems under /oldroot cannot be unmounted we can still lazily unmount
+ * them to unblock /oldroot. They serve no function to us anymore and should be
+ * memory-only and hence safe to unmount like this. */
+ if (in_initrd() &&
+ PATH_STARTSWITH_SET(m->path, "/oldroot/dev", "/oldroot/proc", "/oldroot/sys")) {
+ log_info("Lazily unmounting '%s' instead.", m->path);
+ r = umount2(m->path, MNT_FORCE | MNT_DETACH);
+ if (r < 0)
+ log_error_errno(errno, "Failed to lazily unmount %s: %m", m->path);
+ }
}
_exit(r < 0 ? EXIT_FAILURE : EXIT_SUCCESS);