From 7c23f95c2cbc8f61d2ebc0574fcf16b5512a36e9 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 14 Mar 2025 16:13:48 +0100 Subject: [PATCH] udev-builtin-blkid: skip GPT dissection unless we actually have partition support --- src/udev/udev-builtin-blkid.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/udev/udev-builtin-blkid.c b/src/udev/udev-builtin-blkid.c index 363f07c24ae..1448fa3f048 100644 --- a/src/udev/udev-builtin-blkid.c +++ b/src/udev/udev-builtin-blkid.c @@ -145,8 +145,24 @@ static int find_gpt_root(UdevEvent *event, blkid_probe pr, const char *loop_back * After the initrd→host transition: look at the current block device mounted at / and set the same * properties to its whole block device. */ - if (!device_is_devtype(dev, "disk")) { - log_device_debug(dev, "Skipping GPT root logic on partition block device."); + const char *devnode; + r = sd_device_get_devname(dev, &devnode); + if (r < 0) + return log_device_debug_errno(dev, r, "Failed to get device node: %m"); + + r = block_device_is_whole_disk(dev); + if (r < 0) + return log_device_debug_errno(dev, r, "Unable to determine if device '%s' is a whole-block device: %m", devnode); + if (r == 0) { + log_device_debug(dev, "Invoked on device '%s' which is not a whole-disk block device, ignoring.", devnode); + return 0; + } + + r = blockdev_partscan_enabled(dev); + if (r < 0) + return log_device_debug_errno(dev, r, "Failed to determine if block device '%s' supports partitions: %m", devnode); + if (r == 0) { + log_device_debug(dev, "Invoked on block device '%s' that lacks partition scanning, ignoring.", devnode); return 0; } -- 2.47.3