From: Lennart Poettering Date: Fri, 2 Jun 2023 09:42:08 +0000 (+0200) Subject: detach-loopback: also don't bother detaching loopback block device /usr/ is running off X-Git-Tag: v254-rc1~299^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9959797dbf2f14d4c7131e81e748f4081c9bbb9c;p=thirdparty%2Fsystemd.git detach-loopback: also don't bother detaching loopback block device /usr/ is running off While we are at it, let's also clean this up a bit: unlike DM/MD devices loopback devices are likely partitioned, hence trace the block device through the partition layer and LUKS. --- diff --git a/src/shutdown/detach-loopback.c b/src/shutdown/detach-loopback.c index ceac74223c7..f45960856bc 100644 --- a/src/shutdown/detach-loopback.c +++ b/src/shutdown/detach-loopback.c @@ -175,15 +175,21 @@ static int delete_loopback(const char *device) { static int loopback_points_list_detach(LoopbackDevice **head, bool *changed, bool last_try) { int n_failed = 0, r; - dev_t rootdev = 0; + dev_t rootdev = 0, usrdev = 0; assert(head); assert(changed); - (void) get_block_device("/", &rootdev); + (void) get_block_device_harder("/", &rootdev); + (void) block_get_whole_disk(rootdev, &rootdev); + + (void) get_block_device_harder("/usr", &usrdev); + (void) block_get_whole_disk(usrdev, &usrdev); LIST_FOREACH(loopback_device, m, *head) { - if (major(rootdev) != 0 && rootdev == m->devnum) { + if ((major(rootdev) != 0 && rootdev == m->devnum) || + (major(usrdev) != 0 && usrdev == m->devnum)) { + log_debug("Not detaching loopback device %s that backs the OS itself, skipping.", m->path); n_failed++; continue; }