]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
shutdown: Lazy unmount /oldroot/{dev,proc,sys} 23348/head
authorJan Janssen <medhefgo@web.de>
Wed, 18 May 2022 06:12:31 +0000 (08:12 +0200)
committerJan Janssen <medhefgo@web.de>
Thu, 9 Jun 2022 15:02:50 +0000 (17:02 +0200)
These should not prevent us from cleaning up the remainders of /oldroot
if something in the kernel is blocking these from being unmounted.

src/shutdown/umount.c

index 243a1f80efa4f38de71b94837173edd1d0cf0111..1e691379a45aaad81e1e7acb3f91728fd79def6c 100644 (file)
@@ -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);