init: discoverable root partitions
Subsystems (5)
v3 cover init: discoverable root partitions
DPS [1] defines GPT partition type UUIDs for OS partitions and attributes that control whether such partitions should be automatically discovered. The specification states that:
The OS can discover and mount the necessary file systems with a non-existent or incomplete /etc/fstab file and without the root= kernel command line option.
DPS is already implemented in systemd-gpt-auto-generator [2], which, when embedded in an initrd, indeed allows automatic detection of the root filesystem through its partition type UUID.
This series adds root discovery directly into the kernel so that people who are not using an initrd can still benefit from it.
The scope is deliberately limited to block devices that the kernel can already mount through the root= parameter. Other DPS features, such as setting up LUKS-encrypted partitions, mounting partitions other than root or container setup, remain userspace responsibilities, with no future plan to implement them in the kernel. The intended usage is thus a hybrid approach in which the kernel DPS only mounts the root partition and leaves the remaining setup to userspace (either with DPS or with a classic fstab), just as it does today when root= specifies the root device.
The benefit is being able to boot a kernel with no accompanying bootloader configuration: no root= parameter and no initramfs. The root partition is identified from the existing on-disk metadata instead.
This is useful for booting a kernel manually, for example from the edk2 file browser, or recovering from a lost or corrupted bootloader configuration without having to supply the correct root= argument or load an initrd from the bootloader shell. Finally, it allows systems that otherwise need no initrd to discover their root partition through DPS without introducing an early userspace environment solely for that lookup.
The implementation follows these rules:
- GPT partition type UUIDs are used for automatic discovery policy only. No root=PARTTYPEUUID=xxx cmdline option or similar syntax is added.
- An initramfs providing an early userspace init, a root= command-line option, or a root device supplied by the boot loader takes precedence. Existing working boot configurations therefore retain their current behaviour. Automatic discovery triggers only when booting without any of these, where the kernel would otherwise panic because no root device was specified.
- As required by DPS, discovery is restricted to the disk containing the active EFI System Partition, identified through the LoaderDevicePartUUID EFI variable. This avoids inadvertently selecting a root partition on another disk, assuming partition UUIDs are unique. This is not a security feature: an attacker could duplicate the ESP's PARTUUID on another disk, just as with root=PARTUUID=xxx today.
- If several eligible partitions have the selected type, the first match in block-device enumeration order is used.
- The native architecture's root partition type takes precedence. Where the kernel supports compatible 32-bit userspace, its root partition type is accepted as a fallback.
- Partitions carrying the DPS no-auto attribute are excluded.
- The DPS read-only attribute is intentionally not enforced. The kernel already mounts the root filesystem read-only by default and if the command line requests rw, it takes precedence over the DPS attribute. User space remains responsible for deciding whether a discovered root should later be remounted read-write based on DPS metadata and local policy.
Patch 1 retains GPT partition type UUIDs in partition metadata for early block lookup.
Patch 2 defines the architecture-specific DPS root partition type UUIDs and the derived DPS_ROOT_AUTO_DISCOVERY symbol in Kconfig.
Patch 3 factors out lookup_root_device() so initial root lookup and rootwait retries share the same lookup policy.
Patch 4 implements DPS root discovery through early_lookup_dps_root() and integrates it into the root mount path.
Patch 5 excludes partitions marked no-auto.
Patch 6 adds the compatible 32-bit root partition type UUID as a fallback when no partition with the native type UUID can be found.
Finally, patch 7 documents automatic root discovery.
Tested with the Linux EFI stub [3] and with GRUB [4], which both expose the LoaderDevicePartUUID EFI variable.
[1] The Discoverable Partitions Specification (DPS)
[2] systemd-gpt-auto-generator
[3] commit 0f7d63d9a725 ("efi/libstub: add initial Boot Loader Interface support")
[4] GRUB -- §16.20 bli
---
Changes in v3:
- Rebase on v7.4-rc1.
- Clarify in the cover letter that ESP UUID matching is not a security feature.
- Move the DPS Kconfig symbols from init/Kconfig to block/Kconfig, alongside the root discovery implementation.
- Restrict the LoongArch root partition type UUID to 64-bit kernels, since DPS does not define a root partition type UUID for LoongArch32.
- Reject LoaderDevicePartUUID if it contains trailing characters.
- Document when automatic discovery stops waiting.
Link to v2: https://patch.msgid.link/20261025-discoverable-root_partitions-v2-0-fb77d0821fab@kernel.org
Changes in v2:
- Remove all architectures which do not have CONFIG_EFI.
- Replace the per-architecture UUID headers with Kconfig definitions.
- Move most of the DPS lookup logic to block/early-lookup.c.
- Bail out if ROOT_DEV already exists.
- Hold the disk's open_mutex during lookup so partition scanning finishes before reporting -ENODEV. This is a prerequisite for the next two changes.
- Do an early abort when early_lookup_dps_root() returns -ENODEV.
- Add the secondary partition type UUID as a fallback.
- Small tweaks in log messages.
- Documentation is updated accordingly.
Link to v1: https://lore.kernel.org/r/20260615-discoverable-root_partitions-v1-0-39c78fac42e2@kernel.org
---
Vincent Mailhol (7):
block: store GPT partition type UUID
block: add DPS root partition type UUID definitions
init: factor out root device lookup into lookup_root_device()
block: discover root by DPS partition type UUID
block: skip partitions with DPS no-auto GPT attribute
block: add secondary DPS root partition type UUID
docs: document discoverable root partitions
Documentation/admin-guide/discoverable-root.rst | 46 +++++++++ Documentation/admin-guide/index.rst | 1 + Documentation/admin-guide/kernel-parameters.txt | 5 + block/Kconfig | 21 ++++ block/early-lookup.c | 121 +++++++++++++++++++++++- block/partitions/efi.c | 2 + include/linux/blkdev.h | 15 +++ init/do_mounts.c | 44 +++++++-- 8 files changed, 242 insertions(+), 13 deletions(-)
---
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
change-id: 20260611-discoverable-root_partitions-bdacbada570d
Best regards,
Signature · 1 line
Vincent Mailhol <[email protected]>
PATCH v3 1/7 block: store GPT partition type UUID
DPS [1] identifies OS partitions by GPT partition type UUID.
Keep that UUID in struct partition_meta_info and populate it while scanning GPT partition tables so early root discovery can use it.
[1] The Discoverable Partitions Specification (DPS)
--- block/partitions/efi.c | 1 + include/linux/blkdev.h | 1 + 2 files changed, 2 insertions(+)
block/partitions/efi.c +1 -0
@@ -742,6 +742,7 @@ int efi_partition(struct parsed_partitions *state) info = &state->parts[i +1 ].info;efi_guid_to_str (&ptes[i].unique_partition_guid, info->uuid); +efi_guid_to_str (&ptes[i].partition_type_guid, info->type_uuid);/* Naively convert UTF16-LE to 7 bits. */ label_max = min(ARRAY_SIZE(info->volname) - 1,
include/linux/blkdev.h +1 -0
@@ -67,6 +67,7 @@ extern const struct class block_class;struct partition_meta_info {char uuid[PARTITION_META_INFO_UUIDLTH ]; +char type_uuid[PARTITION_META_INFO_UUIDLTH ];u8 volname[PARTITION_META_INFO_VOLNAMELTH ]; };
Signature · 1 line
2.56.0
PATCH v3 2/7 block: add DPS root partition type UUID definitions
In reply to Vincent MailholDPS [1] assigns a native root partition type UUID to each supported architecture. Add a hidden DPS_ROOT_PARTITION_TYPE_UUID string symbol and populate it from the architecture selected in Kconfig. Only architectures with EFI support in the kernel are added.
Gate the symbol on EFI and EFI_PARTITION because discovery needs block devices, EFI runtime services and GPT partition parsing.
Derive the hidden DPS_ROOT_AUTO_DISCOVERY boolean from whether DPS_ROOT_PARTITION_TYPE_UUID is nonempty.
[1] The Discoverable Partitions Specification (DPS)
--- block/Kconfig | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
block/Kconfig +14 -0
@@ -211,6 +211,20 @@ config BLK_INLINE_ENCRYPTION_FALLBACK source "block/partitions/Kconfig" +config DPS_ROOT_PARTITION_TYPE_UUID + depends on EFI && EFI_PARTITION + string + default "69dad710-2ce4-4e3c-b16c-21a1d49abed3" if ARM + default "b921b045-1df0-41c3-af44-4c6f280d3fae" if ARM64 + default "77055800-792c-4f94-b39a-98c91b762bb6" if LOONGARCH && 64BIT + default "72ec70a6-cf74-40e6-bd49-4bda08e8f224" if RISCV && 64BIT + default "60d5a7fe-8e7d-435c-b714-3dd8162144e1" if RISCV + default "4f68bce3-e8cd-4db1-96e7-fbcaf984b709" if X86_64 + default "44479540-f297-41b2-9af7-d131d5f0458a" if X86 + +config DPS_ROOT_AUTO_DISCOVERY + def_bool DPS_ROOT_PARTITION_TYPE_UUID != "" + config BLK_PM def_bool PM
Signature · 1 line
2.56.0
PATCH v3 3/7 init: factor out root device lookup into lookup_root_device()
In reply to Vincent MailholDPS root detection will also need to work if root_wait is set, meaning that wait_for_root() needs to handle the DPS logic.
Move the early_lookup_bdev() calls and the rootwait error handling into the new lookup_root_device() so later changes can extend the lookup policy without duplicating the rootwait retry logic.
While at it, reword the error message to add the "VFS: " prefix.
--- init/do_mounts.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-)
init/do_mounts.c +15 -8
@@ -402,6 +402,18 @@ void __init mount_root(char *root_device_name) } } +static int __init lookup_root_device (const char *root_device_name,dev_t *dev) +{ +int err; + + err =early_lookup_bdev (root_device_name, dev); +if (err == -EINVAL && root_wait) { +pr_err ("VFS: root= is invalid; disabling rootwait.\n" ); + root_wait =0 ; + } +return err; +} +/* wait for any asynchronous scanning to complete */ static void __init wait_for_root (char *root_device_name) {
@@ -415,7 +427,7 @@ static void __init wait_for_root(char *root_device_name) end =ktime_add_ms (ktime_get_raw (), root_wait);while (!driver_probe_done () || -early_lookup_bdev (root_device_name, &ROOT_DEV ) <0 ) { +lookup_root_device (root_device_name, &ROOT_DEV ) <0 ) {msleep (5 );if (root_wait >0 &&ktime_after (ktime_get_raw (), end))break ;
@@ -440,14 +452,9 @@ static dev_t __init parse_root_device(char *root_device_name)if (strcmp (root_device_name,"/dev/ram" ) ==0 )return Root_RAM0; - error =early_lookup_bdev (root_device_name, &dev); -if (error) { -if (error == -EINVAL && root_wait) { -pr_err ("Disabling rootwait; root= is invalid.\n" ); - root_wait =0 ; - } + error =lookup_root_device (root_device_name, &dev); +if (error)return 0 ; - }return dev; }
Signature · 1 line
2.56.0
PATCH v3 4/7 block: discover root by DPS partition type UUID
In reply to Vincent MailholWhen root= and ROOT_DEV are not set, discover the root block device using the architecture's DPS root partition type UUID. Preserve explicit root selection and an existing ROOT_DEV supplied by the boot protocol.
DPS [1] restricts discovery to the disk containing the active EFI System Partition. Read LoaderDevicePartUUID from the Boot Loader Interface to identify that disk and cache the UUID for subsequent lookup attempts.
Add early_lookup_bdev_by_type_uuid() to select the first matching partition. The EFI System Partition may become visible before the root partition has been registered. Hold the disk's open_mutex during lookup so partition scanning finishes before returning -ENODEV.
Add early_lookup_dps_root() and have lookup_root_device() call it when root= is absent. early_lookup_bdev() is kept unchanged so other callers cannot trigger root discovery inadvertently. Return -EINVAL if the EFI variable cannot be read or does not contain a valid UUID, so lookup_root_device() disables rootwait. Return -EAGAIN if the EFI partition is not available yet so rootwait can retry. Return -ENODEV if its disk has no matching root partition. In that case, have lookup_root_device() disable rootwait, clear the device number and return zero to stop retries. This is safe because partition registration failures do not schedule a rescan, nor does rootwait.
[1] The Discoverable Partitions Specification (DPS)
--- block/early-lookup.c | 117 +++++++++++++++++++++++++++++++++++++++++++++++-- include/linux/blkdev.h | 10 +++++ init/do_mounts.c | 25 +++++++++-- 3 files changed, 145 insertions(+), 7 deletions(-)
block/early-lookup.c +114 -3
@@ -5,10 +5,14 @@*/ #include <linux/blkdev.h> #include <linux/ctype.h> +#include <linux/efi.h> +#include <linux/ucs2_string.h> +#include <linux/uuid.h> struct uuidcmp {const char *uuid;int len; +struct gendisk *disk; };/**
@@ -45,13 +49,11 @@ static int __init match_dev_by_uuid(struct device *dev, const void *data)*/ static int __init devt_from_partuuid (const char *uuid_str,dev_t *devt) { -struct uuidcmp cmp; +struct uuidcmp cmp = { .uuid = uuid_str };struct device *dev =NULL ;int offset =0 ;char *slash; - cmp.uuid = uuid_str; - slash =strchr (uuid_str,'/' );/* Check for optional partition number offset attributes. */ if (slash) {
@@ -252,6 +254,115 @@ int __init early_lookup_bdev(const char *name, dev_t *devt)return devt_from_devnum (name, devt); } +#ifdef CONFIG_DPS_ROOT_AUTO_DISCOVERY +static int __init match_dev_by_type_uuid (struct device *dev,const void *data) +{ +struct block_device *bdev =dev_to_bdev (dev); +const struct uuidcmp *cmp = data; + +return bdev->bd_disk == cmp->disk && bdev->bd_meta_info && + !strcasecmp (cmp->uuid, bdev->bd_meta_info->type_uuid); +} + +/* +* Search the ESP's disk for an eligible partition of the requested type. +* Return -EAGAIN until the ESP is available, or -ENODEV if no match exists. +*/ +static int __init early_lookup_bdev_by_type_uuid (const char *type_uuid, +const char *esp_partuuid, +dev_t *devt) +{ +struct uuidcmp esp_cmp = { + .uuid = esp_partuuid, + .len =UUID_STRING_LEN , + }; +struct uuidcmp type_cmp = { + .uuid = type_uuid, + }; +struct device *esp_dev; +struct device *type_dev; + + esp_dev =class_find_device (&block_class,NULL , &esp_cmp, + &match_dev_by_uuid); +if (!esp_dev) +return -EAGAIN ; + + type_cmp.disk =dev_to_disk (esp_dev); +scoped_guard (mutex, &type_cmp.disk->open_mutex) + type_dev = class_find_device(&block_class, NULL, &type_cmp, + &match_dev_by_type_uuid); +put_device (esp_dev); +if (!type_dev) +return -ENODEV ; + + *devt = type_dev->devt; +pr_info ("VFS: Discovered root partition /dev/%pg with GPT type UUID %s\n" , +dev_to_bdev (type_dev), type_uuid); +put_device (type_dev); +return 0 ; +} + +static int __init efi_get_esp_partuuid (char *partuuid,size_t size) +{ +static efi_guid_t loader_guid__initdata =LINUX_EFI_LOADER_ENTRY_GUID ; +efi_char16_t partuuid_ucs2[UUID_STRING_LEN +1 ] = {}; +unsigned long partuuid_ucs2_size =sizeof (partuuid_ucs2); +efi_status_t status; + +if (!efi_rt_services_supported (EFI_RT_SUPPORTED_GET_VARIABLE )) +return -EOPNOTSUPP ; + + status = efi.get_variable (L"LoaderDevicePartUUID" , &loader_guid,NULL , + &partuuid_ucs2_size, partuuid_ucs2); +if (status !=EFI_SUCCESS ) +return efi_status_to_err (status); + +if (partuuid_ucs2_size !=sizeof (partuuid_ucs2) || + partuuid_ucs2[UUID_STRING_LEN ] || +ucs2_as_utf8 ((u8 *)partuuid, partuuid_ucs2, size) !=UUID_STRING_LEN || + !uuid_is_valid (partuuid)) +return -EINVAL ; + +return 0 ; +} + +/** +* early_lookup_dps_root - discover the root device by DPS partition type UUID +* @dev: receives the discovered device number +* +* Return: 0 on success, -EINVAL if the ESP partition UUID cannot be read or +* is invalid, -EAGAIN if the EFI partition is not yet available, or -ENODEV +* if no matching root exists. +* With DPS disabled, return 0 and set @dev to zero. +*/ +int __init early_lookup_dps_root (dev_t *dev) +{ +static const char root_type_uuids[][UUID_STRING_LEN +1 ]__initconst = { +CONFIG_DPS_ROOT_PARTITION_TYPE_UUID , + }; +static char esp_partuuid[UUID_STRING_LEN +1 ]__initdata ; +int err; + +if (!esp_partuuid[0 ]) { + err =efi_get_esp_partuuid (esp_partuuid,sizeof (esp_partuuid)); +if (err) { +pr_err ("VFS: Unable to get EFI partition UUID: %pe, skipping root partition discovery\n" , +ERR_PTR (err)); +return -EINVAL ; + } + } + +for (int i =0 ; i <ARRAY_SIZE (root_type_uuids); i++) { + err =early_lookup_bdev_by_type_uuid (root_type_uuids[i], + esp_partuuid, dev); +if (err != -ENODEV ) +return err; + } + +return -ENODEV ; +} +#endif /* CONFIG_DPS_ROOT_AUTO_DISCOVERY */ +static char __init *bdevt_str (dev_t devt,char *buf) {if (MAJOR (devt) <=0xff &&MINOR (devt) <=0xff ) {
include/linux/blkdev.h +10 -0
@@ -1748,6 +1748,16 @@ static inline int early_lookup_bdev(const char *pathname, dev_t *dev) }#endif /* CONFIG_BLOCK */ +#ifdef CONFIG_DPS_ROOT_AUTO_DISCOVERY +int __init early_lookup_dps_root (dev_t *dev); +#else +static inline int early_lookup_dps_root (dev_t *dev) +{ + *dev =0 ; +return 0 ; +} +#endif /* CONFIG_DPS_ROOT_AUTO_DISCOVERY */ +int bdev_freeze (struct block_device *bdev);int bdev_thaw (struct block_device *bdev);int bdev_deny_freeze (struct block_device *bdev);
init/do_mounts.c +21 -4
@@ -406,10 +406,24 @@ static int __init lookup_root_device(const char *root_device_name, dev_t *dev) {int err; - err =early_lookup_bdev (root_device_name, dev); +if (root_device_name[0 ]) { + err =early_lookup_bdev (root_device_name, dev); +if (err == -EINVAL && root_wait) { +pr_err ("VFS: root= is invalid; disabling rootwait.\n" ); + root_wait =0 ; + } +return err; + } + + err =early_lookup_dps_root (dev);if (err == -EINVAL && root_wait) { -pr_err ("VFS: root= is invalid; disabling rootwait.\n" ); +pr_err ("VFS: Root discovery is unavailable; disabling rootwait.\n" ); root_wait =0 ; + }else if (err == -ENODEV ) { +pr_err ("VFS: No discoverable root partition found; aborting.\n" ); + root_wait =0 ; + *dev =0 ; +return 0 ; }return err; }
@@ -422,7 +436,10 @@ static void __init wait_for_root(char *root_device_name)if (ROOT_DEV !=0 )return ; -pr_info ("Waiting for root device %s...\n" , root_device_name); +if (root_device_name[0 ]) +pr_info ("Waiting for root device %s...\n" , root_device_name); +else if (IS_ENABLED (CONFIG_DPS_ROOT_AUTO_DISCOVERY )) +pr_info ("Waiting for discoverable root partition...\n" ); end =ktime_add_ms (ktime_get_raw (), root_wait);
@@ -480,7 +497,7 @@ void __init prepare_namespace(void)md_run_setup (); -if (saved_root_name[0 ]) +if (saved_root_name[0 ] || !ROOT_DEV )ROOT_DEV =parse_root_device (saved_root_name);initrd_load ();
Signature · 1 line
2.56.0
[email protected]
AI reviewRe: [PATCH v3 4/7] block: discover root by DPS partition type UUID
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] init: unconditional DPS discovery in prepare_namespace() breaks nodev root - [High] init: DPS root…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] init: unconditional DPS discovery in prepare_namespace() breaks nodev root
- [High] init: DPS root auto-discovery in lookup_root_device() rejected by maintainer --
commit 810f32136ad63589849b2f0f1f1255fa412bff0c
Author: Vincent Mailhol <[email protected]>
block: discover root by DPS partition type UUID
This commit adds root block device discovery using the architecture's Discoverable Partitions Specification (DPS) root partition type UUID when root= and ROOT_DEV are not set. It reads LoaderDevicePartUUID from EFI to locate the disk containing the active EFI System Partition and searches that disk for a matching root partition.
Quoted 9 lines
init/do_mounts.c +0
-1@@ -406,10 +406,24 @@ static int __init lookup_root_device(const char *root_device_name, dev_t *dev) {int err; - err =early_lookup_bdev (root_device_name, dev);
init/do_mounts.c static int __init lookup_root_device(const char *root_device_name, dev_t *dev) · line 418
Quoted 10 lines
init/do_mounts.c +10
-0+if (root_device_name[0 ]) { + err =early_lookup_bdev (root_device_name, dev); +if (err == -EINVAL && root_wait) { +pr_err ("VFS: root= is invalid; disabling rootwait.\n" ); + root_wait =0 ; + } +return err; + } + + err =early_lookup_dps_root (dev);
[Severity: High]
As reported by Christian Brauner on v1 [1], does in-kernel DPS root auto-discovery belong in the kernel?
On v1 of this series, the VFS subsystem maintainer objected to adding DPS auto-discovery to the kernel, noting that DPS is complex userspace policy and should not be implemented in the kernel for root auto-discovery.
This patch still adds early_lookup_dps_root() in block/early-lookup.c and wires it into prepare_namespace() -> parse_root_device() -> lookup_root_device() in init/do_mounts.c when root= and ROOT_DEV are unset.
Quoted 12 lines
init/do_mounts.c +6
-1if (err == -EINVAL && root_wait) { -pr_err ("VFS: root= is invalid; disabling rootwait.\n" ); +pr_err ("VFS: Root discovery is unavailable; disabling rootwait.\n" ); root_wait =0 ; + }else if (err == -ENODEV ) { +pr_err ("VFS: No discoverable root partition found; aborting.\n" ); + root_wait =0 ; + *dev =0 ; +return 0 ; }return err; }
[ ... ]
init/do_mounts.c void __init prepare_namespace(void) · line 501
Quoted 7 lines
init/do_mounts.c +1
-1@@ -480,7 +497,7 @@ void __init prepare_namespace(void)md_run_setup (); -if (saved_root_name[0 ]) +if (saved_root_name[0 ] || !ROOT_DEV )ROOT_DEV =parse_root_device (saved_root_name);
[Severity: High]
Does calling parse_root_device() unconditionally when saved_root_name is empty and ROOT_DEV is 0 cause a regression for nodev root filesystems (such as tmpfs, ramfs, virtiofs, or 9p) configured via rootfstype= without root=?
Previously, when booting without root= and with rootfstype= specifying a nodev filesystem, prepare_namespace() skipped parse_root_device() and left ROOT_DEV as 0, allowing mount_root() to reach case 0 and call mount_nodev_root():
init/do_mounts.c:mount_root() {
switch (ROOT_DEV) {
...
case 0:
if (root_device_name && root_fs_names &&
mount_nodev_root(root_device_name) == 0)
break;
fallthrough;
default:
mount_block_root(root_device_name);
break;
}
}With this change, prepare_namespace() invokes parse_root_device() -> lookup_root_device() -> early_lookup_dps_root() before mount_root() checks for a nodev rootfstype=.
If the system boots via EFI from a disk that happens to contain a partition matching the architecture DPS root type UUID (for example, a VM or host disk with an installed OS image booting a kernel with rootfstype=tmpfs or rootfstype=virtiofs and no root=), early_lookup_dps_root() sets ROOT_DEV to that block partition. mount_root() then skips case 0 and enters mount_block_root() instead of mount_nodev_root(), either hijacking the root mount or panicking when the nodev filesystem rejects /dev/root.
Even when no matching DPS partition exists on the ESP disk (or when LoaderDevicePartUUID is absent), early_lookup_dps_root() and lookup_root_device() unconditionally log KERN_ERR messages such as:
pr_err("VFS: No discoverable root partition found; aborting.\n");or:
pr_err("VFS: Unable to get EFI partition UUID: %pe, skipping root partition discovery\n",
ERR_PTR(err));right before mount_nodev_root() proceeds to mount the nodev root filesystem.
[1] https://lore.kernel.org/r/20260617-irritation-rollen-wirst-7d636cbfec92@brauner
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/20261102-discoverable-root_partitions-v3-0-27f04b69b7ab@kernel.org?part=4
PATCH v3 5/7 block: skip partitions with DPS no-auto GPT attribute
In reply to Vincent MailholDPS [1] defines GPT attribute bit 63 as no-auto. Partitions with this bit set must not be used by automatic discovery.
Store the GPT attributes in partition_meta_info and check GPT_ATTR_NO_AUTO_DISCOVERY when matching a root partition by type UUID.
[1] The Discoverable Partitions Specification (DPS)
--- block/early-lookup.c | 1 + block/partitions/efi.c | 1 + include/linux/blkdev.h | 4 ++++ 3 files changed, 6 insertions(+)
block/early-lookup.c +1 -0
@@ -261,6 +261,7 @@ static int __init match_dev_by_type_uuid(struct device *dev, const void *data)const struct uuidcmp *cmp = data;return bdev->bd_disk == cmp->disk && bdev->bd_meta_info && + !(bdev->bd_meta_info->gpt_attr &GPT_ATTR_NO_AUTO_DISCOVERY ) && !strcasecmp (cmp->uuid, bdev->bd_meta_info->type_uuid); }
block/partitions/efi.c +1 -0
@@ -741,6 +741,7 @@ int efi_partition(struct parsed_partitions *state) state->parts[i +1 ].flags =ADDPART_FLAG_RAID ; info = &state->parts[i +1 ].info; + info->gpt_attr =le64_to_cpu (ptes[i].attributes);efi_guid_to_str (&ptes[i].unique_partition_guid, info->uuid);efi_guid_to_str (&ptes[i].partition_type_guid, info->type_uuid);
include/linux/blkdev.h +4 -0
@@ -5,6 +5,7 @@#ifndef _LINUX_BLKDEV_H#define _LINUX_BLKDEV_H +#include <linux/bits.h> #include <linux/types.h> #include <linux/blk_types.h> #include <linux/blk_plug.h>
@@ -65,10 +66,13 @@ extern const struct class block_class;*/ #define PARTITION_META_INFO_UUIDLTH (UUID_STRING_LEN + 1) +#define GPT_ATTR_NO_AUTO_DISCOVERY BIT_U64(63) +struct partition_meta_info {char uuid[PARTITION_META_INFO_UUIDLTH ];char type_uuid[PARTITION_META_INFO_UUIDLTH ];u8 volname[PARTITION_META_INFO_VOLNAMELTH ]; +u64 gpt_attr; };/**
Signature · 1 line
2.56.0
PATCH v3 6/7 block: add secondary DPS root partition type UUID
In reply to Vincent MailholSome 64-bit architectures can run 32-bit user space. For those configurations, also allow DPS root discovery to use the compatible 32-bit root partition type UUID as a fallback.
Add a secondary root partition type UUID Kconfig symbol and include it in the DPS root lookup when it is defined.
Try the secondary UUID only when the native lookup returns -ENODEV.
The fallback reflects compatibility support built into the kernel. If 32-bit execution is disabled, for example with ia32_emulation=0, the selected root's 32-bit init will fail to execute. Do not check ia32_enabled(): rejecting the fallback would instead leave no discoverable root partition, resulting in a kernel panic either way.
--- block/Kconfig | 7 +++++++ block/early-lookup.c | 3 +++ 2 files changed, 10 insertions(+)
block/Kconfig +7 -0
@@ -222,6 +222,13 @@ config DPS_ROOT_PARTITION_TYPE_UUID default "4f68bce3-e8cd-4db1-96e7-fbcaf984b709" if X86_64 default "44479540-f297-41b2-9af7-d131d5f0458a" if X86 +config DPS_ROOT_PARTITION_TYPE_UUID_SECONDARY + depends on DPS_ROOT_PARTITION_TYPE_UUID != "" && COMPAT + string + default "69dad710-2ce4-4e3c-b16c-21a1d49abed3" if ARM64 + default "60d5a7fe-8e7d-435c-b714-3dd8162144e1" if RISCV + default "44479540-f297-41b2-9af7-d131d5f0458a" if X86_64 && IA32_EMULATION + config DPS_ROOT_AUTO_DISCOVERY def_bool DPS_ROOT_PARTITION_TYPE_UUID != ""
block/early-lookup.c +3 -0
@@ -340,6 +340,9 @@ int __init early_lookup_dps_root(dev_t *dev) {static const char root_type_uuids[][UUID_STRING_LEN +1 ]__initconst = {CONFIG_DPS_ROOT_PARTITION_TYPE_UUID , +#ifdef CONFIG_DPS_ROOT_PARTITION_TYPE_UUID_SECONDARY +CONFIG_DPS_ROOT_PARTITION_TYPE_UUID_SECONDARY , +#endif };static char esp_partuuid[UUID_STRING_LEN +1 ]__initdata ;int err;
Signature · 1 line
2.56.0
PATCH v3 7/7 docs: document discoverable root partitions
In reply to Vincent MailholDocument the automatic root block device discovery feature.
---
Cc: Jonathan Corbet <[email protected]>
Cc: Shuah Khan <[email protected]>
Cc: Randy Dunlap <[email protected]>
Cc: [email protected]
--- Documentation/admin-guide/discoverable-root.rst | 46 +++++++++++++++++++++++++ Documentation/admin-guide/index.rst | 1 + Documentation/admin-guide/kernel-parameters.txt | 5 +++ 3 files changed, 52 insertions(+)
Documentation/admin-guide/discoverable-root.rst new file +46 -0
@@ -0,0 +1,46 @@ +.. SPDX-License-Identifier: GPL-2.0 + +.. _discoverable_root: + +Discoverable root partitions +============================ + +On EFI systems, the kernel can discover the root block device from GPT partition +type UUID metadata on the disk containing the active EFI System Partition. + +This follows the `Discoverable Partitions Specification`_ which defines a list +of architecture-specific root partition type UUIDs. + +An initramfs providing an early userspace ``init``, a ``root=`` kernel +command-line option, or a root device supplied through the boot protocol takes +precedence over this automatic root partition discovery. + +Automatic discovery uses the Boot Loader Interface ``LoaderDevicePartUUID`` EFI +variable to identify the partition whose disk is searched. This variable is +provided by the boot loader or, when the kernel is booted directly by EFI +firmware, by the Linux EFI stub. + +The kernel first searches for the native root partition type UUID. On +architectures that can run compatible 32-bit user space, the matching 32-bit +root partition type UUID may be used as a fallback if no partition with the +native type UUID is found. If multiple partitions on that disk match the +selected type UUID, the kernel selects the first match in block device +enumeration order, but this may change. Systems should not expose multiple +eligible root partitions. + +Partitions marked with the DPS ``no-auto`` GPT attribute are skipped. This +allows a partition with an otherwise discoverable type UUID to opt out from +automatic discovery. + +With ``rootwait`` or ``rootwait=<seconds>``, discovery retries while the EFI +System Partition is unavailable, subject to any specified timeout. Once its disk +has been scanned, discovery either selects an eligible root partition or stops +if none was found. Waiting is also disabled if ``LoaderDevicePartUUID`` is not +available or is malformed. + +The DPS read-only attribute is not enforced by kernel root discovery. The +root filesystem is mounted read-only by default unless ``rw`` is specified, +and user space remains responsible for later remount policy. + +.. _Discoverable Partitions Specification: + https://uapi-group.org/specifications/specs/discoverable_partitions_specification/
Documentation/admin-guide/index.rst +1 -0
@@ -50,6 +50,7 @@ Booting the kernel bootconfig kernel-parameters + discoverable-root efi-stub initrd
Documentation/admin-guide/kernel-parameters.txt +5 -0
@@ -6746,6 +6746,11 @@ Kernel parameters ramdisk, "nfs" and "cifs" for root on a network file system, or "mtd" and "ubi" for mounting from raw flash. + If this option is omitted, the kernel may try to + discover the root block device from the GPT partition + type UUID metadata when additional requirements are met. + See Documentation/admin-guide/discoverable-root.rst. + rootdelay= [KNL] Delay (in seconds) to pause before attempting to mount the root filesystem
Signature · 1 line
2.56.0
Christian Brauner
maintainerQuoted 2 lines · Vincent Mailhol
This series adds root discovery directly into the kernel so that people who are not using an initrd can still benefit from it.
Nothing has changed since
https://lore.kernel.org/r/20260617-irritation-rollen-wirst-7d636cbfec92@brauner
Quoted 6 lines · Christian Brauner
Quoted 2 lines · Vincent Mailhol
This series adds root discovery directly into the kernel so that people who are not using an initrd can still benefit from it.
Nothing has changed since
https://lore.kernel.org/r/20260617-irritation-rollen-wirst-7d636cbfec92@brauner
I replied to your earlier message to explain my position but did not hear back.
Since v1, I have rewritten the cover letter to better explain why I think implementing a subset of DPS in the kernel makes a difference. The relevant paragraph is:
This is useful for booting a kernel manually, for example from the edk2 file browser, or recovering from a lost or corrupted bootloader configuration without having to supply the correct root= argument or load an initrd from the bootloader shell. Finally, it allows systems that otherwise need no initrd to discover their root partition through DPS without introducing an early userspace environment solely for that lookup.
Similarly, I clarified the scope to address your concern about the complexity of DPS:
The scope is deliberately limited to block devices that the kernel can already mount through the root= parameter. Other DPS features, such as setting up LUKS-encrypted partitions, mounting partitions other than root or container setup, remain userspace responsibilities, with no future plan to implement them in the kernel. The intended usage is thus a hybrid approach in which the kernel DPS only mounts the root partition and leaves the remaining setup to userspace (either with DPS or with a classic fstab), just as it does today when root= specifies the root device.
I would appreciate hearing whether these use cases and the limited scope address your concerns.
Yours sincerely,
Vincent Mailhol
Christian Brauner
maintainerQuoted 2 lines · Vincent Mailhol
I would appreciate hearing whether these use cases and the limited scope address your concerns.
I don't think they do. The scope was never the problem. DPS is userspace policy and a subset of it in the kernel is still policy in the kernel. It seems just wrong.
Quoted 7 lines
This is useful for booting a kernel manually, for example from the edk2 file browser, or recovering from a lost or corrupted bootloader configuration without having to supply the correct root= argument or load an initrd from the bootloader shell. Finally, it allows systems that otherwise need no initrd to discover their root partition through DPS without introducing an early userspace environment solely for that lookup.
The kernel can already find the root partition without an initrd though? For example, via root=PARTUUID= and root=PARTLABEL=.
And if you want to pick something in the edk2 file browser and have it boot then pick a UKI. It carries its command line and its initrd in the PE binary so there's nothing to type and no second file to find. And that initrd can do DPS just fine. Everything beyond that is bootloader or early userspace policy.