Skip to contentSkip to conversation

init: discoverable root partitions, a.k.a. an omittable "root=" cmdline option

PATCH Superseded Vincent Mailhol 7 participants 32 messages Jun 15 – Jun 17

Subsystems (16)
Documentation Arm (32-bit) x86 VFS +12 more subsystems

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover init: discoverable root partitions, a.k.a. an omittable "root=" cmdline option

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 this discovery feature directly into the kernel so that people who are not using systemd or not using an initrd can still benefit from it. The implementation follows the same model as systemd-gpt-auto-generator:

- GPT partition type UUIDs are used for automatic discovery policy only. No root=PARTTYPEUUID=xxx cmdline option or similar syntax is added.

- The root= cmdline option takes precedence. This prevents unexpected behaviour.

- Only the disk with the active EFI System Partition is scanned, as required by DPS. The disk is identified through the Boot Loader Interface LoaderDevicePartUUID EFI variable.

The DPS no-auto attribute is also implemented, giving another option for the user to disable this auto discovery. However, the DPS read-only attribute is intentionally not enforced. The kernel already mounts the root filesystem read-only by default unless the command line requests rw, and user space remains responsible for deciding whether a discovered root should later be remounted read-write based on DPS metadata and local policy. The other partition type UUIDs (home, swap, var...) are also out of scope for the same reason: user space remains responsible for mounting anything other than the root partition.

Patch 1 adds the ARCH_HAS_DPS_ROOT_PARTITION_TYPE_UUID capability and the hidden CONFIG_DPS_ROOT_AUTO_DISCOVERY Kconfig symbol used to signal whether the feature is available. Patches 2 to 12 declare the ARCH_HAS_DPS_ROOT_PARTITION_TYPE_UUID capability for the supported architectures and define their architecture-specific root partition type UUID values in asm/dps_root.h.

Patches 13 to 16 make the GPT partition type UUID and the no-auto attribute available during early block lookup.

Patch 17 is a small code refactor that prepares for patch 18, which updates the root mount path so that, when root= is omitted, the kernel reads LoaderDevicePartUUID and uses the early block lookup infrastructure to discover the DPS root partition on that disk.

Finally, patch 19 documents this automatic root discovery feature.

Tested with GRUB, which implements the LoaderDevicePartUUID EFI variable in its bli module [3]. With this, I was able to boot a kernel with a completely empty cmdline and no initrd.

[1] The Discoverable Partitions Specification (DPS)

[2] systemd-gpt-auto-generator

[3] GRUB -- §16.2 bli

---
Vincent Mailhol (19):
init: add DPS root partition type UUID capability
alpha: define DPS root partition type UUID
arc: define DPS root partition type UUID
arm: define DPS root partition type UUID
arm64: define DPS root partition type UUID
loongarch: define DPS root partition type UUID
mips: define DPS root partition type UUIDs
parisc: define DPS root partition type UUID
powerpc: define DPS root partition type UUIDs
riscv: define DPS root partition type UUIDs
s390: define DPS root partition type UUIDs
x86: define DPS root partition type UUIDs
block: store GPT partition type UUID
block: add early_lookup_bdev_by_type_uuid()
block: store GPT attributes as a raw value
block: don't discover partition with DPS no-auto GPT attribute
init: factor out root device lookup into lookup_root_device()
init: discover root by DPS partition type UUID
docs: document discoverable root partitions

 Documentation/admin-guide/discoverable-root.rst | 33 +++++++++
 Documentation/admin-guide/index.rst             |  1 +
 Documentation/admin-guide/kernel-parameters.txt |  5 ++
 arch/alpha/Kconfig                              |  1 +
 arch/alpha/include/asm/dps_root.h               |  8 +++
 arch/arc/Kconfig                                |  1 +
 arch/arc/include/asm/dps_root.h                 |  8 +++
 arch/arm/Kconfig                                |  1 +
 arch/arm/include/asm/dps_root.h                 |  8 +++
 arch/arm64/Kconfig                              |  1 +
 arch/arm64/include/asm/dps_root.h               |  8 +++
 arch/loongarch/Kconfig                          |  1 +
 arch/loongarch/include/asm/dps_root.h           |  8 +++
 arch/mips/Kconfig                               |  1 +
 arch/mips/include/asm/dps_root.h                | 20 ++++++
 arch/parisc/Kconfig                             |  1 +
 arch/parisc/include/asm/dps_root.h              |  8 +++
 arch/powerpc/Kconfig                            |  1 +
 arch/powerpc/include/asm/dps_root.h             | 16 +++++
 arch/riscv/Kconfig                              |  1 +
 arch/riscv/include/asm/dps_root.h               | 12 ++++
 arch/s390/Kconfig                               |  1 +
 arch/s390/include/asm/dps_root.h                | 12 ++++
 arch/x86/Kconfig                                |  1 +
 arch/x86/include/asm/dps_root.h                 | 12 ++++
 block/blk.h                                     |  1 +
 block/early-lookup.c                            | 68 +++++++++++++++++-
 block/partitions/core.c                         |  2 +
 block/partitions/efi.c                          |  3 +
 block/partitions/efi.h                          | 11 ++-
 include/linux/blk_types.h                       |  1 +
 include/linux/blkdev.h                          |  5 ++
 include/linux/root_dev.h                        |  6 ++
 init/Kconfig                                    |  6 ++
 init/do_mounts.c                                | 94 ++++++++++++++++++++++++-
 35 files changed, 355 insertions(+), 12 deletions(-)

---
base-commit: 36808d5e983985bbda87e01059cccc071fe3ec8d
change-id: 20260611-discoverable-root_partitions-bdacbada570d

Best regards,

Signature · 1 line
Vincent Mailhol <[email protected]>
#1 lore raw

PATCH 1/19 init: add DPS root partition type UUID capability

DPS [1] assigns native root partition type UUIDs per architecture.

Add the ARCH_HAS_DPS_ROOT_PARTITION_TYPE_UUID config option so that architectures can opt in.

Architectures that support this feature should define DPS_ROOT_PARTITION_TYPE_UUID in asm/dps_root.h as a string representation of the architecture's DPS root partition type UUID.

Add the hidden DPS_ROOT_AUTO_DISCOVERY symbol for the combination of BLOCK, EFI and ARCH_HAS_DPS_ROOT_PARTITION_TYPE_UUID, and use it to expose DPS_ROOT_PARTITION_TYPE_UUID from the common linux/root_dev.h header only when all prerequisites are met.

[1] The Discoverable Partitions Specification (DPS)

---
 include/linux/root_dev.h | 6 ++++++
 init/Kconfig             | 6 ++++++
 2 files changed, 12 insertions(+)
include/linux/root_dev.h +6 -0
index 847c9a06101b..6b52a10b0bca 100644
@@ -5,6 +5,12 @@
 #include <linux/major.h>
 #include <linux/types.h>
 #include <linux/kdev_t.h>
+#include <linux/uuid.h>
+
+#ifdef CONFIG_DPS_ROOT_AUTO_DISCOVERY
+#include <asm/dps_root.h>
+static_assert(sizeof(DPS_ROOT_PARTITION_TYPE_UUID) == UUID_STRING_LEN + 1);
+#endif
 
 enum {
 	Root_NFS = MKDEV(UNNAMED_MAJOR, 255),
init/Kconfig +6 -0
index 147da6370bf0..982c6ad9da4d 100644
@@ -2287,6 +2287,12 @@ config ARCH_HAS_PREPARE_SYNC_CORE_CMD
 config ARCH_HAS_SYNC_CORE_BEFORE_USERMODE
 	bool
 
+config ARCH_HAS_DPS_ROOT_PARTITION_TYPE_UUID
+	bool
+
+config DPS_ROOT_AUTO_DISCOVERY
+	def_bool BLOCK && EFI && ARCH_HAS_DPS_ROOT_PARTITION_TYPE_UUID
+
 # It may be useful for an architecture to override the definitions of the
 # SYSCALL_DEFINE() and __SYSCALL_DEFINEx() macros in <linux/syscalls.h>
 # and the COMPAT_ variants in <linux/compat.h>, in particular to use a
Signature · 1 line
2.53.0
#2 lore raw

PATCH 2/19 alpha: define DPS root partition type UUID

In reply to Vincent Mailhol

DPS [1] assigns GPT partition type UUIDs to operating system partitions. Root partitions use architecture-specific type UUIDs so the OS can discover the intended root filesystem without relying on a root= cmdline option.

Define DPS_ROOT_PARTITION_TYPE_UUID in asm/dps_root.h for alpha and select ARCH_HAS_DPS_ROOT_PARTITION_TYPE_UUID.

[1] The Discoverable Partitions Specification (DPS)

Cc Richard Henderson <[email protected]>
Cc Matt Turner <[email protected]>
Cc Magnus Lindholm <[email protected]>
---
 arch/alpha/Kconfig                | 1 +
 arch/alpha/include/asm/dps_root.h | 8 ++++++++
 2 files changed, 9 insertions(+)
arch/alpha/Kconfig +1 -0
index 7b7dafe7d9df..400cbb7525c8 100644
@@ -5,6 +5,7 @@ config ALPHA
 	select ARCH_32BIT_USTAT_F_TINODE
 	select ARCH_HAS_CURRENT_STACK_POINTER
 	select ARCH_HAS_DMA_OPS if PCI
+	select ARCH_HAS_DPS_ROOT_PARTITION_TYPE_UUID
 	select ARCH_MIGHT_HAVE_PC_PARPORT
 	select ARCH_MIGHT_HAVE_PC_SERIO
 	select ARCH_MODULE_NEEDS_WEAK_PER_CPU if SMP
arch/alpha/include/asm/dps_root.h new file +8 -0
new file mode 100644
index 000000000000..7f70a83f72de
@@ -0,0 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef _ASM_ALPHA_DPS_ROOT_H
+#define _ASM_ALPHA_DPS_ROOT_H
+
+#define DPS_ROOT_PARTITION_TYPE_UUID "6523f8ae-3eb1-4e2a-a05a-18b695ae656f"
+
+#endif /* _ASM_ALPHA_DPS_ROOT_H */
Signature · 1 line
2.53.0
#3 lore raw

PATCH 3/19 arc: define DPS root partition type UUID

In reply to Vincent Mailhol

DPS [1] assigns GPT partition type UUIDs to operating system partitions. Root partitions use architecture-specific type UUIDs so the OS can discover the intended root filesystem without relying on a root= cmdline option.

Define DPS_ROOT_PARTITION_TYPE_UUID in asm/dps_root.h for ARC and select ARCH_HAS_DPS_ROOT_PARTITION_TYPE_UUID.

[1] The Discoverable Partitions Specification (DPS)

---
 arch/arc/Kconfig                | 1 +
 arch/arc/include/asm/dps_root.h | 8 ++++++++
 2 files changed, 9 insertions(+)
arch/arc/Kconfig +1 -0
index 2ed7186c81c5..cc3a57a0111f 100644
@@ -10,6 +10,7 @@ config ARC
 	select ARCH_HAS_CACHE_LINE_SIZE
 	select ARCH_HAS_DEBUG_VM_PGTABLE
 	select ARCH_HAS_DMA_PREP_COHERENT
+	select ARCH_HAS_DPS_ROOT_PARTITION_TYPE_UUID
 	select ARCH_HAS_PTE_SPECIAL
 	select ARCH_HAS_SETUP_DMA_OPS
 	select ARCH_HAS_SYNC_DMA_FOR_CPU
arch/arc/include/asm/dps_root.h new file +8 -0
new file mode 100644
index 000000000000..c9db3ddf1a53
@@ -0,0 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef _ASM_ARC_DPS_ROOT_H
+#define _ASM_ARC_DPS_ROOT_H
+
+#define DPS_ROOT_PARTITION_TYPE_UUID "d27f46ed-2919-4cb8-bd25-9531f3c16534"
+
+#endif /* _ASM_ARC_DPS_ROOT_H */
Signature · 1 line
2.53.0
#4 lore raw

PATCH 4/19 arm: define DPS root partition type UUID

In reply to Vincent Mailhol

DPS [1] assigns GPT partition type UUIDs to operating system partitions. Root partitions use architecture-specific type UUIDs so the OS can discover the intended root filesystem without relying on a root= cmdline option.

Define DPS_ROOT_PARTITION_TYPE_UUID in asm/dps_root.h for ARM and select ARCH_HAS_DPS_ROOT_PARTITION_TYPE_UUID.

[1] The Discoverable Partitions Specification (DPS)

---
 arch/arm/Kconfig                | 1 +
 arch/arm/include/asm/dps_root.h | 8 ++++++++
 2 files changed, 9 insertions(+)
arch/arm/Kconfig +1 -0
index 73e6647bea46..deedb5d808fb 100644
@@ -14,6 +14,7 @@ config ARM
 	select ARCH_HAS_DMA_ALLOC if MMU
 	select ARCH_HAS_DMA_OPS
 	select ARCH_HAS_DMA_WRITE_COMBINE if !ARM_DMA_MEM_BUFFERABLE
+	select ARCH_HAS_DPS_ROOT_PARTITION_TYPE_UUID
 	select ARCH_HAS_ELF_RANDOMIZE
 	select ARCH_HAS_FORTIFY_SOURCE
 	select ARCH_HAS_KEEPINITRD
arch/arm/include/asm/dps_root.h new file +8 -0
new file mode 100644
index 000000000000..e9f0f24bcac2
@@ -0,0 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef _ASM_ARM_DPS_ROOT_H
+#define _ASM_ARM_DPS_ROOT_H
+
+#define DPS_ROOT_PARTITION_TYPE_UUID "69dad710-2ce4-4e3c-b16c-21a1d49abed3"
+
+#endif /* _ASM_ARM_DPS_ROOT_H */
Signature · 1 line
2.53.0
#5 lore raw

PATCH 5/19 arm64: define DPS root partition type UUID

In reply to Vincent Mailhol

DPS [1] assigns GPT partition type UUIDs to operating system partitions. Root partitions use architecture-specific type UUIDs so the OS can discover the intended root filesystem without relying on a root= cmdline option.

Define DPS_ROOT_PARTITION_TYPE_UUID in asm/dps_root.h for arm64 and select ARCH_HAS_DPS_ROOT_PARTITION_TYPE_UUID.

[1] The Discoverable Partitions Specification (DPS)

---
 arch/arm64/Kconfig                | 1 +
 arch/arm64/include/asm/dps_root.h | 8 ++++++++
 2 files changed, 9 insertions(+)
arch/arm64/Kconfig +1 -0
index fe60738e5943..190f8dde63b2 100644
@@ -26,6 +26,7 @@ config ARM64
 	select ARCH_HAS_DEBUG_VM_PGTABLE
 	select ARCH_HAS_DMA_OPS if XEN
 	select ARCH_HAS_DMA_PREP_COHERENT
+	select ARCH_HAS_DPS_ROOT_PARTITION_TYPE_UUID
 	select ARCH_HAS_ACPI_TABLE_UPGRADE if ACPI
 	select ARCH_HAS_FAST_MULTIPLIER
 	select ARCH_HAS_FORTIFY_SOURCE
arch/arm64/include/asm/dps_root.h new file +8 -0
new file mode 100644
index 000000000000..7344f9a52343
@@ -0,0 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef _ASM_ARM64_DPS_ROOT_H
+#define _ASM_ARM64_DPS_ROOT_H
+
+#define DPS_ROOT_PARTITION_TYPE_UUID "b921b045-1df0-41c3-af44-4c6f280d3fae"
+
+#endif /* _ASM_ARM64_DPS_ROOT_H */
Signature · 1 line
2.53.0
#6 lore raw

PATCH 6/19 loongarch: define DPS root partition type UUID

In reply to Vincent Mailhol

DPS [1] assigns GPT partition type UUIDs to operating system partitions. Root partitions use architecture-specific type UUIDs so the OS can discover the intended root filesystem without relying on a root= cmdline option.

Define DPS_ROOT_PARTITION_TYPE_UUID in asm/dps_root.h for LoongArch64 and select ARCH_HAS_DPS_ROOT_PARTITION_TYPE_UUID.

[1] The Discoverable Partitions Specification (DPS)

---
 arch/loongarch/Kconfig                | 1 +
 arch/loongarch/include/asm/dps_root.h | 8 ++++++++
 2 files changed, 9 insertions(+)
arch/loongarch/Kconfig +1 -0
index 606597da46b8..64c27740b8a1 100644
@@ -17,6 +17,7 @@ config LOONGARCH
 	select ARCH_HAS_CPU_FINALIZE_INIT
 	select ARCH_HAS_CURRENT_STACK_POINTER
 	select ARCH_HAS_DEBUG_VM_PGTABLE
+	select ARCH_HAS_DPS_ROOT_PARTITION_TYPE_UUID
 	select ARCH_HAS_FAST_MULTIPLIER
 	select ARCH_HAS_FORTIFY_SOURCE
 	select ARCH_HAS_KCOV
arch/loongarch/include/asm/dps_root.h new file +8 -0
new file mode 100644
index 000000000000..6022b60428ad
@@ -0,0 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef _ASM_LOONGARCH_DPS_ROOT_H
+#define _ASM_LOONGARCH_DPS_ROOT_H
+
+#define DPS_ROOT_PARTITION_TYPE_UUID "77055800-792c-4f94-b39a-98c91b762bb6"
+
+#endif /* _ASM_LOONGARCH_DPS_ROOT_H */
Signature · 1 line
2.53.0
#7 lore raw

PATCH 7/19 mips: define DPS root partition type UUIDs

In reply to Vincent Mailhol

DPS [1] assigns GPT partition type UUIDs to operating system partitions. Root partitions use architecture-specific type UUIDs so the OS can discover the intended root filesystem without relying on a root= cmdline option.

Define DPS_ROOT_PARTITION_TYPE_UUID in asm/dps_root.h for the MIPS endian and 32/64-bit variants described by the specification and select ARCH_HAS_DPS_ROOT_PARTITION_TYPE_UUID.

[1] The Discoverable Partitions Specification (DPS)

---
 arch/mips/Kconfig                |  1 +
 arch/mips/include/asm/dps_root.h | 20 ++++++++++++++++++++
 2 files changed, 21 insertions(+)
arch/mips/Kconfig +1 -0
index 4364f3dba688..15dd7d336cfa 100644
@@ -10,6 +10,7 @@ config MIPS
 	select ARCH_HAS_CURRENT_STACK_POINTER
 	select ARCH_HAS_DEBUG_VIRTUAL if !64BIT
 	select ARCH_HAS_DMA_OPS if MACH_JAZZ
+	select ARCH_HAS_DPS_ROOT_PARTITION_TYPE_UUID
 	select ARCH_HAS_FORTIFY_SOURCE
 	select ARCH_HAS_KCOV
 	select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE if !EVA
arch/mips/include/asm/dps_root.h new file +20 -0
new file mode 100644
index 000000000000..b07cab7399ad
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef _ASM_MIPS_DPS_ROOT_H
+#define _ASM_MIPS_DPS_ROOT_H
+
+#ifdef CONFIG_CPU_LITTLE_ENDIAN
+#ifdef CONFIG_64BIT
+#define DPS_ROOT_PARTITION_TYPE_UUID "700bda43-7a34-4507-b179-eeb93d7a7ca3"
+#else
+#define DPS_ROOT_PARTITION_TYPE_UUID "37c58c8a-d913-4156-a25f-48b1b64e07f0"
+#endif
+#else
+#ifdef CONFIG_64BIT
+#define DPS_ROOT_PARTITION_TYPE_UUID "d113af76-80ef-41b4-bdb6-0cff4d3d4a25"
+#else
+#define DPS_ROOT_PARTITION_TYPE_UUID "e9434544-6e2c-47cc-bae2-12d6deafb44c"
+#endif
+#endif
+
+#endif /* _ASM_MIPS_DPS_ROOT_H */
Signature · 1 line
2.53.0
#8 lore raw

PATCH 8/19 parisc: define DPS root partition type UUID

In reply to Vincent Mailhol

DPS [1] assigns GPT partition type UUIDs to operating system partitions. Root partitions use architecture-specific type UUIDs so the OS can discover the intended root filesystem without relying on a root= cmdline option.

Define DPS_ROOT_PARTITION_TYPE_UUID in asm/dps_root.h for parisc and select ARCH_HAS_DPS_ROOT_PARTITION_TYPE_UUID.

[1] The Discoverable Partitions Specification (DPS)

Cc "James E.J. Bottomley" <[email protected]>
Cc Helge Deller <[email protected]>
---
 arch/parisc/Kconfig                | 1 +
 arch/parisc/include/asm/dps_root.h | 8 ++++++++
 2 files changed, 9 insertions(+)
arch/parisc/Kconfig +1 -0
index d3afac2f0d9b..94f0a758176a 100644
@@ -24,6 +24,7 @@ config PARISC
 	select ARCH_STACKWALK
 	select ARCH_HAS_CACHE_LINE_SIZE
 	select ARCH_HAS_DEBUG_VM_PGTABLE
+	select ARCH_HAS_DPS_ROOT_PARTITION_TYPE_UUID
 	select HAVE_RELIABLE_STACKTRACE
 	select RTC_CLASS
 	select RTC_DRV_GENERIC
arch/parisc/include/asm/dps_root.h new file +8 -0
new file mode 100644
index 000000000000..bf475cd5b01c
@@ -0,0 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef _ASM_PARISC_DPS_ROOT_H
+#define _ASM_PARISC_DPS_ROOT_H
+
+#define DPS_ROOT_PARTITION_TYPE_UUID "1aacdb3b-5444-4138-bd9e-e5c2239b2346"
+
+#endif /* _ASM_PARISC_DPS_ROOT_H */
Signature · 1 line
2.53.0
#12 lore raw

PATCH 9/19 powerpc: define DPS root partition type UUIDs

In reply to Vincent Mailhol

DPS [1] assigns GPT partition type UUIDs to operating system partitions. Root partitions use architecture-specific type UUIDs so the OS can discover the intended root filesystem without relying on a root= cmdline option.

Define DPS_ROOT_PARTITION_TYPE_UUID in asm/dps_root.h for the powerpc endian and 32/64-bit variants described by the specification and select ARCH_HAS_DPS_ROOT_PARTITION_TYPE_UUID.

[1] The Discoverable Partitions Specification (DPS)

Cc Madhavan Srinivasan <[email protected]>
Cc Michael Ellerman <[email protected]>
---
 arch/powerpc/Kconfig                |  1 +
 arch/powerpc/include/asm/dps_root.h | 16 ++++++++++++++++
 2 files changed, 17 insertions(+)
arch/powerpc/Kconfig +1 -0
index e93df95b79e7..e611280a6057 100644
@@ -134,6 +134,7 @@ config PPC
 	select ARCH_HAS_DEVMEM_IS_ALLOWED
 	select ARCH_HAS_DMA_MAP_DIRECT 		if PPC_PSERIES
 	select ARCH_HAS_DMA_OPS			if PPC64
+	select ARCH_HAS_DPS_ROOT_PARTITION_TYPE_UUID
 	select ARCH_HAS_FORTIFY_SOURCE
 	select ARCH_HAS_GCOV_PROFILE_ALL
 	select ARCH_HAS_GIGANTIC_PAGE		if ARCH_SUPPORTS_HUGETLBFS
arch/powerpc/include/asm/dps_root.h new file +16 -0
new file mode 100644
index 000000000000..6b3592a73d3d
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef _ASM_POWERPC_DPS_ROOT_H
+#define _ASM_POWERPC_DPS_ROOT_H
+
+#ifdef CONFIG_PPC64
+#ifdef CONFIG_CPU_LITTLE_ENDIAN
+#define DPS_ROOT_PARTITION_TYPE_UUID "c31c45e6-3f39-412e-80fb-4809c4980599"
+#else
+#define DPS_ROOT_PARTITION_TYPE_UUID "912ade1d-a839-4913-8964-a10eee08fbd2"
+#endif
+#else
+#define DPS_ROOT_PARTITION_TYPE_UUID "1de3f1ef-fa98-47b5-8dcd-4a860a654d78"
+#endif
+
+#endif /* _ASM_POWERPC_DPS_ROOT_H */
Signature · 1 line
2.53.0
#13 lore raw

PATCH 10/19 riscv: define DPS root partition type UUIDs

In reply to Vincent Mailhol

DPS [1] assigns GPT partition type UUIDs to operating system partitions. Root partitions use architecture-specific type UUIDs so the OS can discover the intended root filesystem without relying on a root= cmdline option.

Define DPS_ROOT_PARTITION_TYPE_UUID in asm/dps_root.h for the RISC-V 32/64-bit variants described by the specification and select ARCH_HAS_DPS_ROOT_PARTITION_TYPE_UUID.

[1] The Discoverable Partitions Specification (DPS)

---
 arch/riscv/Kconfig                |  1 +
 arch/riscv/include/asm/dps_root.h | 12 ++++++++++++
 2 files changed, 13 insertions(+)
arch/riscv/Kconfig +1 -0
index 1a2fadccd4c4..526be67e858a 100644
@@ -28,6 +28,7 @@ config RISCV
 	select ARCH_HAS_DEBUG_VIRTUAL if MMU
 	select ARCH_HAS_DEBUG_VM_PGTABLE
 	select ARCH_HAS_DEBUG_WX
+	select ARCH_HAS_DPS_ROOT_PARTITION_TYPE_UUID
 	select ARCH_HAS_ELF_CORE_EFLAGS if BINFMT_ELF && ELF_CORE
 	select ARCH_HAS_FAST_MULTIPLIER
 	select ARCH_HAS_FORTIFY_SOURCE
arch/riscv/include/asm/dps_root.h new file +12 -0
new file mode 100644
index 000000000000..86f8e1dbd6ad
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef _ASM_RISCV_DPS_ROOT_H
+#define _ASM_RISCV_DPS_ROOT_H
+
+#ifdef CONFIG_64BIT
+#define DPS_ROOT_PARTITION_TYPE_UUID "72ec70a6-cf74-40e6-bd49-4bda08e8f224"
+#else
+#define DPS_ROOT_PARTITION_TYPE_UUID "60d5a7fe-8e7d-435c-b714-3dd8162144e1"
+#endif
+
+#endif /* _ASM_RISCV_DPS_ROOT_H */
Signature · 1 line
2.53.0
#14 lore raw

PATCH 11/19 s390: define DPS root partition type UUIDs

In reply to Vincent Mailhol

DPS [1] assigns GPT partition type UUIDs to operating system partitions. Root partitions use architecture-specific type UUIDs so the OS can discover the intended root filesystem without relying on a root= cmdline option.

Define DPS_ROOT_PARTITION_TYPE_UUID in asm/dps_root.h for the s390 (32-bit) and s390x (64-bit) variants described by the specification and select ARCH_HAS_DPS_ROOT_PARTITION_TYPE_UUID.

[1] The Discoverable Partitions Specification (DPS)

Cc Heiko Carstens <[email protected]>
Cc Vasily Gorbik <[email protected]>
Cc Alexander Gordeev <[email protected]>
---
 arch/s390/Kconfig                |  1 +
 arch/s390/include/asm/dps_root.h | 12 ++++++++++++
 2 files changed, 13 insertions(+)
arch/s390/Kconfig +1 -0
index 9921a3772bf7..af2cf67fffd7 100644
@@ -91,6 +91,7 @@ config S390
 	select ARCH_HAS_DEBUG_WX
 	select ARCH_HAS_DEVMEM_IS_ALLOWED
 	select ARCH_HAS_DMA_OPS if PCI
+	select ARCH_HAS_DPS_ROOT_PARTITION_TYPE_UUID
 	select ARCH_HAS_ELF_RANDOMIZE
 	select ARCH_HAS_FORCE_DMA_UNENCRYPTED
 	select ARCH_HAS_FORTIFY_SOURCE
arch/s390/include/asm/dps_root.h new file +12 -0
new file mode 100644
index 000000000000..e72e44a66097
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef _ASM_S390_DPS_ROOT_H
+#define _ASM_S390_DPS_ROOT_H
+
+#ifdef CONFIG_64BIT
+#define DPS_ROOT_PARTITION_TYPE_UUID "5eead9a9-fe09-4a1e-a1d7-520d00531306"
+#else
+#define DPS_ROOT_PARTITION_TYPE_UUID "08a7acea-624c-4a20-91e8-6e0fa67d23f9"
+#endif
+
+#endif /* _ASM_S390_DPS_ROOT_H */
Signature · 1 line
2.53.0
#15 lore raw

PATCH 12/19 x86: define DPS root partition type UUIDs

In reply to Vincent Mailhol

DPS [1] assigns GPT partition type UUIDs to operating system partitions. Root partitions use architecture-specific type UUIDs so the OS can discover the intended root filesystem without relying on a root= cmdline option.

Define DPS_ROOT_PARTITION_TYPE_UUID in asm/dps_root.h for the x86 32/64-bit variants described by the specification and select ARCH_HAS_DPS_ROOT_PARTITION_TYPE_UUID.

[1] The Discoverable Partitions Specification (DPS)

Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Dave Hansen <[email protected]>
---
 arch/x86/Kconfig                |  1 +
 arch/x86/include/asm/dps_root.h | 12 ++++++++++++
 2 files changed, 13 insertions(+)
arch/x86/Kconfig +1 -0
index b875d2f27e48..6b6e7b56f972 100644
@@ -82,6 +82,7 @@ config X86
 	select ARCH_HAS_DEBUG_VM_PGTABLE	if !X86_PAE
 	select ARCH_HAS_DEVMEM_IS_ALLOWED
 	select ARCH_HAS_DMA_OPS			if GART_IOMMU || XEN
+	select ARCH_HAS_DPS_ROOT_PARTITION_TYPE_UUID
 	select ARCH_HAS_EARLY_DEBUG		if KGDB
 	select ARCH_HAS_ELF_RANDOMIZE
 	select ARCH_HAS_EXECMEM_ROX		if X86_64 && STRICT_MODULE_RWX
arch/x86/include/asm/dps_root.h new file +12 -0
new file mode 100644
index 000000000000..7c6ba5519d88
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef _ASM_X86_DPS_ROOT_H
+#define _ASM_X86_DPS_ROOT_H
+
+#ifdef CONFIG_X86_64
+#define DPS_ROOT_PARTITION_TYPE_UUID "4f68bce3-e8cd-4db1-96e7-fbcaf984b709"
+#else
+#define DPS_ROOT_PARTITION_TYPE_UUID "44479540-f297-41b2-9af7-d131d5f0458a"
+#endif
+
+#endif /* _ASM_X86_DPS_ROOT_H */
Signature · 1 line
2.53.0
#21 lore raw

PATCH 13/19 block: store GPT partition type UUID

In reply to Vincent Mailhol

DPS [1] identifies OS partitions by GPT partition type UUID.

Keep that UUID in partition_meta_info and populate it while scanning EFI 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
index 9865d59093fa..4a3835ed9561 100644
@@ -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
index 890128cdea1c..8ce85d21a1f4 100644
@@ -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.53.0
#22 lore raw

PATCH 14/19 block: add early_lookup_bdev_by_type_uuid()

In reply to Vincent Mailhol

Add early_lookup_bdev_by_type_uuid() to find the root block device by its GPT type UUID on the disk containing the active EFI System Partition.

DPS [1] requires OS partition discovery to be limited to the disk containing the active EFI System Partition. Reuse the existing block class lookup and UUID matching callback to identify that disk, then do a second lookup constrained to it. If the disk contains several partitions with a matching type UUID, use the first match, following the DPS discovery rule.

Extend struct uuidcmp with the new disk field so that it can be used in the new match_dev_by_type_uuid() callback function.

Update devt_from_partuuid() to initialize cmp with a designated initializer so that the new cmp.disk field is zero-initialized. This is not strictly needed, but keeps the code cleaner.

[1] The Discoverable Partitions Specification (DPS)

---
 block/early-lookup.c   | 67 +++++++++++++++++++++++++++++++++++++++++++++++---
 include/linux/blkdev.h |  4 +++
 2 files changed, 68 insertions(+), 3 deletions(-)
block/early-lookup.c +64 -3
index 3fb57f7d2b12..cd10785e70ac 100644
@@ -5,10 +5,12 @@
  */
 #include <linux/blkdev.h>
 #include <linux/ctype.h>
+#include <linux/uuid.h>
 
 struct uuidcmp {
 	const char *uuid;
 	int len;
+	struct gendisk *disk;
 };
 
 /**
@@ -45,13 +47,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 +252,67 @@ int __init early_lookup_bdev(const char *name, dev_t *devt)
 	return devt_from_devnum(name, devt);
 }
 
+#ifdef CONFIG_DPS_ROOT_AUTO_DISCOVERY
+/**
+ * match_dev_by_type_uuid - callback for finding a partition using its type UUID
+ * @dev:	device passed in by the caller
+ * @data:	opaque pointer to the desired struct uuidcmp to match
+ *
+ * Returns: 1 if the device matches, and 0 otherwise.
+ */
+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);
+}
+
+/**
+ * early_lookup_bdev_by_type_uuid - look up a partition by its type UUID
+ * @type_uuid:		partition type UUID to search for
+ * @efi_partuuid:	partition UUID identifying the active EFI partition
+ * @devt:		matching dev_t result
+ *
+ * This helper follows the Discoverable Partitions Specification rules. It uses
+ * @efi_partuuid to find the disk containing the active EFI System Partition,
+ * then searches only partitions on that disk for the partition type UUID
+ * specified by @type_uuid.
+ *
+ * Returns: 0 on success or a negative error code on failure.
+ */
+int __init early_lookup_bdev_by_type_uuid(const char *type_uuid,
+					  const char *efi_partuuid, dev_t *devt)
+{
+	struct uuidcmp efi_cmp = {
+		.uuid = efi_partuuid,
+		.len = UUID_STRING_LEN,
+	};
+	struct uuidcmp type_cmp = {
+		.uuid = type_uuid,
+	};
+	struct device *efi_dev;
+	struct device *type_dev;
+
+	efi_dev = class_find_device(&block_class, NULL, &efi_cmp,
+				    &match_dev_by_uuid);
+	if (!efi_dev)
+		return -ENODEV;
+
+	type_cmp.disk = dev_to_disk(efi_dev);
+	type_dev = class_find_device(&block_class, NULL, &type_cmp,
+				     &match_dev_by_type_uuid);
+	put_device(efi_dev);
+	if (!type_dev)
+		return -ENODEV;
+
+	*devt = type_dev->devt;
+	put_device(type_dev);
+	return 0;
+}
+#endif
+
 static char __init *bdevt_str(dev_t devt, char *buf)
 {
 	if (MAJOR(devt) <= 0xff && MINOR(devt) <= 0xff) {
include/linux/blkdev.h +4 -0
index 8ce85d21a1f4..c2b7d07c92e7 100644
@@ -1800,6 +1800,10 @@ void sync_bdevs(bool wait);
 void bdev_statx(const struct path *path, struct kstat *stat, u32 request_mask);
 void printk_all_partitions(void);
 int __init early_lookup_bdev(const char *pathname, dev_t *dev);
+#ifdef CONFIG_DPS_ROOT_AUTO_DISCOVERY
+int __init early_lookup_bdev_by_type_uuid(const char *type_uuid,
+					  const char *efi_partuuid, dev_t *dev);
+#endif
 #else
 static inline void invalidate_bdev(struct block_device *bdev)
 {
Signature · 1 line
2.53.0
#23 lore raw

PATCH 15/19 block: store GPT attributes as a raw value

In reply to Vincent Mailhol

struct _gpt_entry_attributes currently models the GPT partition entry attributes field with bitfields. This is broken on machines using the __BIG_ENDIAN_BITFIELD ABI because GPT always stores the attributes on disk as a 64-bit little-endian.

No current code consumes individual fields from that structure. So just remove struct _gpt_entry_attributes entirely and replace it by an __le64 value in struct _gpt_entry.

---
 block/partitions/efi.h | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
block/partitions/efi.h +1 -7
index 84b9f36b9e47..1f56f93b2804 100644
@@ -75,18 +75,12 @@ typedef struct _gpt_header {
 	 */
 } __packed gpt_header;
 
-typedef struct _gpt_entry_attributes {
-	u64 required_to_function:1;
-	u64 reserved:47;
-        u64 type_guid_specific:16;
-} __packed gpt_entry_attributes;
-
 typedef struct _gpt_entry {
 	efi_guid_t partition_type_guid;
 	efi_guid_t unique_partition_guid;
 	__le64 starting_lba;
 	__le64 ending_lba;
-	gpt_entry_attributes attributes;
+	__le64 attributes;
 	__le16 partition_name[72/sizeof(__le16)];
 } __packed gpt_entry;
 
Signature · 1 line
2.53.0
#24 lore raw

PATCH 16/19 block: don't discover partition with DPS no-auto GPT attribute

In reply to Vincent Mailhol

DPS [1] defines GPT attribute bit 63 as no-auto. Partitions with this bit set must not be used by automatic discovery.

Add the new GPT_ATTRIBUTE_NO_AUTO flag to designate the GPT attribute bit 63.

Add the new ADDPART_FLAG_NO_AUTO flag and set it when GPT_ATTRIBUTE_NO_AUTO is set during the partition scan. Then, propagate it to the new BD_NO_AUTO_DISCOVERY flag.

Finally, add a condition to match_dev_by_type_uuid() to exclude any partition with that flag from the automatic discovery.

[1] The Discoverable Partitions Specification (DPS)

---
 block/blk.h               | 1 +
 block/early-lookup.c      | 1 +
 block/partitions/core.c   | 2 ++
 block/partitions/efi.c    | 2 ++
 block/partitions/efi.h    | 3 +++
 include/linux/blk_types.h | 1 +
 6 files changed, 10 insertions(+)
block/blk.h +1 -0
index b998a7761faf..14e0f349ff14 100644
@@ -604,6 +604,7 @@ void blk_free_ext_minor(unsigned int minor);
 #define ADDPART_FLAG_RAID	1
 #define ADDPART_FLAG_WHOLEDISK	2
 #define ADDPART_FLAG_READONLY	4
+#define ADDPART_FLAG_NO_AUTO	8
 int bdev_add_partition(struct gendisk *disk, int partno, sector_t start,
 		sector_t length);
 int bdev_del_partition(struct gendisk *disk, int partno);
block/early-lookup.c +1 -0
index cd10785e70ac..8db0abec141e 100644
@@ -266,6 +266,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_test_flag(bdev, BD_NO_AUTO_DISCOVERY) &&
 	       !strcasecmp(cmp->uuid, bdev->bd_meta_info->type_uuid);
 }
 
block/partitions/core.c +2 -0
index 5d5332ce586b..4529ea1d308e 100644
@@ -382,6 +382,8 @@ static struct block_device *add_partition(struct gendisk *disk, int partno,
 
 	if (flags & ADDPART_FLAG_READONLY)
 		bdev_set_flag(bdev, BD_READ_ONLY);
+	if (flags & ADDPART_FLAG_NO_AUTO)
+		bdev_set_flag(bdev, BD_NO_AUTO_DISCOVERY);
 
 	/* everything is up and running, commence */
 	err = xa_insert(&disk->part_tbl, partno, bdev, GFP_KERNEL);
block/partitions/efi.c +2 -0
index 4a3835ed9561..50c21625e256 100644
@@ -739,6 +739,8 @@ int efi_partition(struct parsed_partitions *state)
 		/* If this is a RAID volume, tell md */
 		if (!efi_guidcmp(ptes[i].partition_type_guid, PARTITION_LINUX_RAID_GUID))
 			state->parts[i + 1].flags = ADDPART_FLAG_RAID;
+		if (le64_to_cpu(ptes[i].attributes) & GPT_ATTRIBUTE_NO_AUTO)
+			state->parts[i + 1].flags |= ADDPART_FLAG_NO_AUTO;
 
 		info = &state->parts[i + 1].info;
 		efi_guid_to_str(&ptes[i].unique_partition_guid, info->uuid);
block/partitions/efi.h +3 -0
index 1f56f93b2804..fb50edb66e84 100644
@@ -11,6 +11,7 @@
 #ifndef FS_PART_EFI_H_INCLUDED
 #define FS_PART_EFI_H_INCLUDED
 
+#include <linux/bits.h>
 #include <linux/types.h>
 #include <linux/fs.h>
 #include <linux/kernel.h>
@@ -30,6 +31,8 @@
 #define GPT_HEADER_REVISION_V1 0x00010000
 #define GPT_PRIMARY_PARTITION_TABLE_LBA 1
 
+#define GPT_ATTRIBUTE_NO_AUTO BIT_U64(63)
+
 #define PARTITION_SYSTEM_GUID \
     EFI_GUID( 0xC12A7328, 0xF81F, 0x11d2, \
               0xBA, 0x4B, 0x00, 0xA0, 0xC9, 0x3E, 0xC9, 0x3B) 
include/linux/blk_types.h +1 -0
index 8808ee76e73c..c6cdc99b0490 100644
@@ -54,6 +54,7 @@ struct block_device {
 #ifdef CONFIG_FAIL_MAKE_REQUEST
 #define BD_MAKE_IT_FAIL		(1u<<12)
 #endif
+#define BD_NO_AUTO_DISCOVERY	(1u<<13)
 	dev_t			bd_dev;
 	struct address_space	*bd_mapping;	/* page cache */
 
Signature · 1 line
2.53.0
#25 lore raw

PATCH 17/19 init: factor out root device lookup into lookup_root_device()

In reply to Vincent Mailhol

DPS root detection will also need to work if root_wait is set, meaning that wait_for_root() needs to handle the DPS logic.

Move early_lookup_bdev() out of wait_for_root() into the new lookup_root_device() so later changes can extend the lookup policy without duplicating the retry logic.

---
 init/do_mounts.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
init/do_mounts.c +6 -1
index 95e0b3a0f711..5fb5aeb88da9 100644
@@ -402,6 +402,11 @@ void __init mount_root(char *root_device_name)
 	}
 }
 
+static int __init lookup_root_device(char *root_device_name)
+{
+	return early_lookup_bdev(root_device_name, &ROOT_DEV);
+}
+
 /* wait for any asynchronous scanning to complete */
 static void __init wait_for_root(char *root_device_name)
 {
@@ -415,7 +420,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) < 0) {
 		msleep(5);
 		if (root_wait > 0 && ktime_after(ktime_get_raw(), end))
 			break;
Signature · 1 line
2.53.0
#26 lore raw

PATCH 18/19 init: discover root by DPS partition type UUID

In reply to Vincent Mailhol

When the root= cmdline option is absent, try to discover the root block device using the architecture's DPS root partition type UUID.

DPS limits root discovery to the disk containing the active EFI System Partition. Read LoaderDevicePartUUID from the Boot Loader Interface and pass it to early_lookup_bdev_by_type_uuid() so the block lookup only considers partitions on that disk.

Print a dedicated wait message while waiting for a discoverable root partition and emit an informational message when discovery succeeds.

If LoaderDevicePartUUID cannot be read or does not contain a valid UUID, clear root_wait so the kernel does not keep retrying a discovery path that cannot succeed.

---
 init/do_mounts.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 87 insertions(+), 2 deletions(-)
init/do_mounts.c +87 -2
index 5fb5aeb88da9..20c176945b32 100644
@@ -10,6 +10,7 @@
 #include <linux/delay.h>
 #include <linux/mount.h>
 #include <linux/device.h>
+#include <linux/efi.h>
 #include <linux/init.h>
 #include <linux/fs.h>
 #include <linux/initrd.h>
@@ -19,6 +20,8 @@
 #include <linux/ramfs.h>
 #include <linux/shmem_fs.h>
 #include <linux/ktime.h>
+#include <linux/ucs2_string.h>
+#include <linux/uuid.h>
 
 #include <linux/nfs_fs.h>
 #include <linux/nfs_fs_sb.h>
@@ -402,9 +405,86 @@ void __init mount_root(char *root_device_name)
 	}
 }
 
+#ifdef CONFIG_DPS_ROOT_AUTO_DISCOVERY
+static char efi_partuuid[EFI_VARIABLE_GUID_LEN + 1] __initdata;
+
+static int __init efi_loader_get_device_part_uuid(char *efi_uuid, size_t size)
+{
+	efi_char16_t efi_uuid_ucs2[EFI_VARIABLE_GUID_LEN + 1] = {};
+	unsigned long efi_uuid_ucs2_size = sizeof(efi_uuid_ucs2);
+	efi_status_t status;
+
+	if (!efi_rt_services_supported(EFI_RT_SUPPORTED_GET_VARIABLE))
+		return -EOPNOTSUPP;
+
+	status = efi.get_variable(L"LoaderDevicePartUUID",
+				  &LINUX_EFI_LOADER_ENTRY_GUID, NULL,
+				  &efi_uuid_ucs2_size, efi_uuid_ucs2);
+	if (status != EFI_SUCCESS)
+		return efi_status_to_err(status);
+
+	if (ucs2_as_utf8((u8 *)efi_uuid, efi_uuid_ucs2, size) != UUID_STRING_LEN ||
+	    !uuid_is_valid(efi_uuid))
+		return -EINVAL;
+
+	return 0;
+}
+
+static int __init lookup_dps_root(dev_t *dev)
+{
+	static const char dps_root_partition_type_uuid[] __initconst =
+		DPS_ROOT_PARTITION_TYPE_UUID;
+	int err;
+
+	err = early_lookup_bdev_by_type_uuid(dps_root_partition_type_uuid,
+					     efi_partuuid, dev);
+	if (!err)
+		pr_info("VFS: Discovered root partition with GPT type UUID %s\n",
+			dps_root_partition_type_uuid);
+
+	return err;
+}
+
+static dev_t __init try_dps_root_discovery(void)
+{
+	dev_t dev;
+	int err;
+
+	err = efi_loader_get_device_part_uuid(efi_partuuid,
+					      sizeof(efi_partuuid));
+	if (err) {
+		pr_err("VFS: Unable to get LoaderDevicePartUUID EFI variable: %pe, skipping root partition discovery\n",
+			ERR_PTR(err));
+		if (root_wait) {
+			pr_err("Disabling rootwait\n");
+			root_wait = 0;
+		}
+		return 0;
+	}
+
+	if (!lookup_dps_root(&dev))
+		return dev;
+
+	return 0;
+}
+#else
+static int __init lookup_dps_root(dev_t *dev)
+{
+	return 0;
+}
+
+static dev_t __init try_dps_root_discovery(void)
+{
+	return 0;
+}
+#endif
+
 static int __init lookup_root_device(char *root_device_name)
 {
-	return early_lookup_bdev(root_device_name, &ROOT_DEV);
+	if (root_device_name[0])
+		return early_lookup_bdev(root_device_name, &ROOT_DEV);
+	else
+		return lookup_dps_root(&ROOT_DEV);
 }
 
 /* wait for any asynchronous scanning to complete */
@@ -415,7 +495,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,6 +563,8 @@ void __init prepare_namespace(void)
 
 	if (saved_root_name[0])
 		ROOT_DEV = parse_root_device(saved_root_name);
+	else
+		ROOT_DEV = try_dps_root_discovery();
 
 	initrd_load();
 
Signature · 1 line
2.53.0
#27 lore raw

PATCH 19/19 docs: document discoverable root partitions

In reply to Vincent Mailhol

Document the automatic root block device discovery feature.

---
 Documentation/admin-guide/discoverable-root.rst | 33 +++++++++++++++++++++++++
 Documentation/admin-guide/index.rst             |  1 +
 Documentation/admin-guide/kernel-parameters.txt |  5 ++++
 3 files changed, 39 insertions(+)
Documentation/admin-guide/discoverable-root.rst new file +33 -0
new file mode 100644
index 000000000000..9645bf39e405
@@ -0,0 +1,33 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+.. _discoverable_root:
+
+Discoverable root partitions
+============================
+
+On EFI systems using a supported architecture, 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.
+
+Specifying ``root=`` on the kernel command line takes precedence and entirely
+disables this automatic root partition discovery.
+
+The disk to search is identified by the Boot Loader Interface
+``LoaderDevicePartUUID`` EFI variable. If multiple partitions on that disk match
+the architecture root partition type UUID, the kernel selects the first match in
+block device enumeration order. Systems should not expose multiple eligible root
+partitions unless that ordering is intended.
+
+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.
+
+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
index cd28dfe91b06..0d9c2796ae09 100644
@@ -50,6 +50,7 @@ Booting the kernel
 
    bootconfig
    kernel-parameters
+   discoverable-root
    efi-stub
    initrd
 
Documentation/admin-guide/kernel-parameters.txt +5 -0
index f68bf1cdb53b..c9bfa010883c 100644
@@ -6696,6 +6696,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.53.0
#16 lore raw

Re: [PATCH 12/19] x86: define DPS root partition type UUIDs

In reply to Vincent Mailhol

arch/x86/include/asm/dps_root.h line 10

Quoted 5 lines · Vincent Mailhol
arch/x86/include/asm/dps_root.h new file +5 -0
+#ifdef CONFIG_X86_64
+#define DPS_ROOT_PARTITION_TYPE_UUID "4f68bce3-e8cd-4db1-96e7-fbcaf984b709"
+#else
+#define DPS_ROOT_PARTITION_TYPE_UUID "44479540-f297-41b2-9af7-d131d5f0458a"
+#endif

This doesn't make a whole lot of sense to me. 64-bit kernels can run 32-bit userspace just fine.

But this #ifdef as proposed means that only a 32-bit *OR* 64-bit kernel can auto-discover a given partition.

I kinda think you should just have an array of strings for these things, maybe glued together with some preprocessor magic. Logically something like this:

const char* const uuids[] = {

#ifdef CONFIG_ARM64
	"b921b045-1df0-41c3-af44-4c6f280d3fae"
#endif
#ifdef CONFIG_X86_64
	"4f68bce3-e8cd-4db1-96e7-fbcaf984b709",
#endif
#if defined(CONFIG_X86) && defined(CONFIG_COMPAT32)
	"44479540-f297-41b2-9af7-d131d5f0458a",

#endif
...
};

... and then search the array. I honestly don't think you need to sprinkle UUIDs all over the architectures.

It could probably also be done almost entirely in Kconfig. This could be in, say block/partitions/Kconfig, or arch/*/Kconfig:

config DPS_ROOT_PARTITION_TYPE_UUID_1

	string
        default "4f68bce3-e8cd-4db1-96e7-fbcaf984b709" if X86_64
	default "b921b045-1df0-41c3-af44-4c6f280d3fae" if ARM64
	...

config DPS_ROOT_PARTITION_TYPE_UUID_2

	string
        default "44479540-f297-41b2-9af7-..." if X86 && COMPAT_32

const char* const uuids[] = {
#ifdef CONFIG_DPS_ROOT_PARTITION_TYPE_UUID_1
CONFIG_DPS_ROOT_PARTITION_TYPE_UUID_1
#endif
#ifdef CONFIG_DPS_ROOT_PARTITION_TYPE_UUID_2
CONFIG_DPS_ROOT_PARTITION_TYPE_UUID_2
#endif
...
};

There are a lot of ways to do this. I'm just not a super big fan of the current proposal.

So, boiling it down:

1. Should more than one UUID be supported per kernel build?
2. Should the UUIDs be defined in arch code or generic code?
3. Kconfig or #ifdefs?

maintainer
#28 lore raw
In reply to Vincent Mailhol
Quoted 4 lines · Vincent Mailhol

Tested with GRUB, which implements the LoaderDevicePartUUID EFI variable in its bli module [3]. With this, I was able to boot a kernel with a completely empty cmdline and no initrd.

Quoted 8 lines

[1] The Discoverable Partitions Specification (DPS)

[2] systemd-gpt-auto-generator

[3] GRUB -- §16.2 bli

So what does that thing, tied to EFI as it is, have to do with architectures where
* firmware is rather unlike EFI
* firmware wouldn't know what to do with GPT
* GRUB is *not* ported to, let alone used
such as, say it, the very first one mentioned at your [1]?

Or is that conditional upon "if anyone wants to design replacement firmware for those, and if they agree to follow our wishlist"?

#17 lore raw

Re: [PATCH 12/19] x86: define DPS root partition type UUIDs

In reply to Dave Hansen
Quoted 8 lines · Dave Hansen

There are a lot of ways to do this. I'm just not a super big fan of the current proposal.

So, boiling it down:

1. Should more than one UUID be supported per kernel build?
2. Should the UUIDs be defined in arch code or generic code?
3. Kconfig or #ifdefs?

Further questions ... why do this in the kernel? Seems perfectly suited to be in initramfs where we can throw away the code after boot.

maintainer
#9 lore raw

Re: [PATCH 08/19] parisc: define DPS root partition type UUID

In reply to Vincent Mailhol
Quoted 11 lines · Vincent Mailhol

DPS [1] assigns GPT partition type UUIDs to operating system partitions. Root partitions use architecture-specific type UUIDs so the OS can discover the intended root filesystem without relying on a root= cmdline option.

Define DPS_ROOT_PARTITION_TYPE_UUID in asm/dps_root.h for parisc and select ARCH_HAS_DPS_ROOT_PARTITION_TYPE_UUID.

[1] The Discoverable Partitions Specification (DPS) Link:
https://uapi-group.org/specifications/specs/discoverable_partitions_specification/

How are you planning to make this work for parisc? Some systems have a PALO boot partition (fdisk type 0xf0) but the more modern way is to place palo inside a hidden ext4 inode in /boot. The way parisc IODC works is very similar to the way MSDOS boots with the palo location table in the first block so I theorize that would probably work for gpt partitions as well ... I'm just not sure anyone has tested it.

However, to get this to work with PALO for auto discovery, you'd need palo patches to recognize the DPS UUID and no-one seems to have submitted anything to palo for this.

Regards,

James

#19 lore raw

Re: [PATCH 12/19] x86: define DPS root partition type UUIDs

In reply to Dave Hansen
Quoted 56 lines · Dave Hansen

arch/x86/include/asm/dps_root.h line 10

Quoted 5 lines · Vincent Mailhol
arch/x86/include/asm/dps_root.h new file +5 -0
+#ifdef CONFIG_X86_64
+#define DPS_ROOT_PARTITION_TYPE_UUID "4f68bce3-e8cd-4db1-96e7-fbcaf984b709"
+#else
+#define DPS_ROOT_PARTITION_TYPE_UUID "44479540-f297-41b2-9af7-d131d5f0458a"
+#endif

This doesn't make a whole lot of sense to me. 64-bit kernels can run 32-bit userspace just fine.

But this #ifdef as proposed means that only a 32-bit *OR* 64-bit kernel can auto-discover a given partition.

I kinda think you should just have an array of strings for these things, maybe glued together with some preprocessor magic. Logically something like this:

const char* const uuids[] = {

#ifdef CONFIG_ARM64
	"b921b045-1df0-41c3-af44-4c6f280d3fae"
#endif
#ifdef CONFIG_X86_64
	"4f68bce3-e8cd-4db1-96e7-fbcaf984b709",
#endif
#if defined(CONFIG_X86) && defined(CONFIG_COMPAT32)
	"44479540-f297-41b2-9af7-d131d5f0458a",

#endif
...
};

... and then search the array. I honestly don't think you need to sprinkle UUIDs all over the architectures.

It could probably also be done almost entirely in Kconfig. This could be in, say block/partitions/Kconfig, or arch/*/Kconfig:

config DPS_ROOT_PARTITION_TYPE_UUID_1

	string
        default "4f68bce3-e8cd-4db1-96e7-fbcaf984b709" if X86_64
	default "b921b045-1df0-41c3-af44-4c6f280d3fae" if ARM64
	...

config DPS_ROOT_PARTITION_TYPE_UUID_2

	string
        default "44479540-f297-41b2-9af7-..." if X86 && COMPAT_32

const char* const uuids[] = {
#ifdef CONFIG_DPS_ROOT_PARTITION_TYPE_UUID_1
CONFIG_DPS_ROOT_PARTITION_TYPE_UUID_1
#endif
#ifdef CONFIG_DPS_ROOT_PARTITION_TYPE_UUID_2
CONFIG_DPS_ROOT_PARTITION_TYPE_UUID_2
#endif
...
};

Quoted 6 lines

There are a lot of ways to do this. I'm just not a super big fan of the current proposal.

So, boiling it down:

1. Should more than one UUID be supported per kernel build?

I didn't pay much attention to this, but this is a very good point.

The Discoverable Partitions Specification is not clear about this point. All it has to say is:

On systems *with matching architecture*, the first partition with this type UUID on the disk containing the active EFI ESP is automatically mounted to the root directory /.

Does an x86_32 system match an x86_64 partition? Wouldn't make sense. Does an x86_64 system match an x86_32 partition? Could be.

My feeling is that the intent was an *exact* match. This is supported by the implementation in systemd which just check against SD_GPT_ROOT_NATIVE (which corresponds to the exact match).

https://github.com/systemd/systemd/blob/main/src/udev/udev-builtin-blkid.c#L243-L247

*But* there are some hints about a secondary UUID. In my terminal I have:

  $ systemd-id128 show root root-secondary
  NAME           ID                              
  root           4f68bce3e8cd4db196e7fbcaf984b709
  root-secondary 44479540f29741b29af7d131d5f0458a

where root is the x86_64 and root-secondary is x86_32. So although I see no match logic in the code, the ID table have it!

That said, your points make sense to me, and I would be supportive to allow a search for a secondary UUID as a kernel extension. If we do so, I think the only constraint should be to make sure that we check for the exact match first (e.g. check x86_64 type before x86_32 type).

Would that make sense?

Quoted 1 line

2. Should the UUIDs be defined in arch code or generic code?

I think that you convinced me to put it in generic code.

Quoted 1 line

3. Kconfig or #ifdefs?

I would say Kconfig. If we go for the exact match only, that would be:

CONFIG_DPS_ROOT_PARTITION_TYPE_UUID

If we allow more as an extension, that would become:

- CONFIG_DPS_ROOT_PARTITION_TYPE_UUID for the exact match
- CONFIG_DPS_ROOT_PARTITION_TYPE_UUID_SECONDARY for the compatible one.

The drawback is that some entries will be in both:

config DPS_ROOT_PARTITION_TYPE_UUID
string
default "4f68bce3-e8cd-4db1-96e7-fbcaf984b709" if X86_64 default "44479540-f297-41b2-9af7-d131d5f0458a" if X86

  config DPS_ROOT_PARTITION_TYPE_UUID_SECONDARY
  	string
  	  default "44479540-f297-41b2-9af7-d131d5f0458a" if X86_64 && COMPAT_32

And I don't think we need more than two.

A bonus question: should those Kconfig entries be hidden? I prefer the hidden option because it doesn't add that much code and I thought this was not worth bothering the user with one more menuconfig question. But I would be happy to change if people this this is worth an menuconfig entry.

Yours sincerely,
Vincent Mailhol

maintainer
#10 lore raw

Re: [PATCH 08/19] parisc: define DPS root partition type UUID

In reply to James Bottomley
Quoted 8 lines · James Bottomley
Quoted 7 lines · Vincent Mailhol

DPS [1] assigns GPT partition type UUIDs to operating system partitions. Root partitions use architecture-specific type UUIDs so the OS can discover the intended root filesystem without relying on a root= cmdline option.

Define DPS_ROOT_PARTITION_TYPE_UUID in asm/dps_root.h for parisc and select ARCH_HAS_DPS_ROOT_PARTITION_TYPE_UUID.

Vincent, first of all thank you for at least trying to including parisc (and other niche Linux ports) in the specification! (whatever the outcome is!)

Quoted 11 lines
Quoted 3 lines

[1] The Discoverable Partitions Specification (DPS) Link:
https://uapi-group.org/specifications/specs/discoverable_partitions_specification/

How are you planning to make this work for parisc? Some systems have a PALO boot partition (fdisk type 0xf0) but the more modern way is to place palo inside a hidden ext4 inode in /boot. The way parisc IODC works is very similar to the way MSDOS boots with the palo location table in the first block so I theorize that would probably work for gpt partitions as well ... I'm just not sure anyone has tested it.

Quoted 3 lines

However, to get this to work with PALO for auto discovery, you'd need palo patches to recognize the DPS UUID and no-one seems to have submitted anything to palo for this.

Maybe it's not necessary that palo does this job?
palo could stay as is and load kernel and the initrd.
Then the kernel (or the scripts in initrd) could try to find the root partition on it's own (and handle GPT discs).

I even once started porting grub to parisc (which is currently on hold because I'm busy with other stuff). If I ever finish it, having such a mechanism/constant already in place is IMHO beneficial.

Helge

#29 lore raw
In reply to Al Viro
Quoted 9 lines · Al Viro
Quoted 7 lines · Vincent Mailhol

Tested with GRUB, which implements the LoaderDevicePartUUID EFI variable in its bli module [3]. With this, I was able to boot a kernel with a completely empty cmdline and no initrd.

[1] The Discoverable Partitions Specification (DPS)

Quoted 8 lines
Quoted 5 lines

[2] systemd-gpt-auto-generator

[3] GRUB -- §16.2 bli

So what does that thing, tied to EFI as it is, have to do with architectures where
* firmware is rather unlike EFI

I made CONFIG_DPS_ROOT_AUTO_DISCOVERY depend on CONFIG_EFI for this reason.

Quoted 3 lines

* firmware wouldn't know what to do with GPT
* GRUB is *not* ported to, let alone used
such as, say it, the very first one mentioned at your [1]?

Fair point. I just did:

  $ git grep "^config EFI$"
  arch/arm/Kconfig:config EFI
  arch/arm64/Kconfig:config EFI
  arch/loongarch/Kconfig:config EFI
  arch/riscv/Kconfig:config EFI
  arch/x86/Kconfig:config EFI

Anything not in this list is dead code at the moment.

Quoted 2 lines

Or is that conditional upon "if anyone wants to design replacement firmware for those, and if they agree to follow our wishlist"?

No, it was just an oversight from my side. I will just keep arm, arm64, loongarch, riscv and x86 in my v2.

Yours sincerely,
Vincent Mailhol

#18 lore raw

Re: [PATCH 12/19] x86: define DPS root partition type UUIDs

In reply to Matthew Wilcox
Quoted 11 lines · Matthew Wilcox
Quoted 8 lines · Dave Hansen

There are a lot of ways to do this. I'm just not a super big fan of the current proposal.

So, boiling it down:

1. Should more than one UUID be supported per kernel build?
2. Should the UUIDs be defined in arch code or generic code?
3. Kconfig or #ifdefs?

Further questions ... why do this in the kernel?

Most of the plumbing was already there so that the feature is still tiny. It seems like a reasonable trade-off to me.

Quoted 2 lines

Seems perfectly suited to be in initramfs where we can throw away the code after boot.

The added code uses the __init attribute for this exact reason: so that its memory can be reclaimed after.

Signature · 2 lines
Yours sincerely,
Vincent Mailhol
#11 lore raw

Re: [PATCH 08/19] parisc: define DPS root partition type UUID

In reply to Helge Deller
Quoted 7 lines · Helge Deller
Quoted 6 lines · James Bottomley
Quoted 5 lines · Vincent Mailhol

DPS [1] assigns GPT partition type UUIDs to operating system partitions. Root partitions use architecture-specific type UUIDs so the OS can discover the intended root filesystem without relying on a root=  cmdline option.

Quoted 6 lines
Quoted 2 lines
Quoted 2 lines

Define DPS_ROOT_PARTITION_TYPE_UUID in asm/dps_root.h for parisc and select ARCH_HAS_DPS_ROOT_PARTITION_TYPE_UUID.

Vincent, first of all thank you for at least trying to including parisc (and other
niche Linux ports) in the specification! (whatever the outcome is!)

You are welcome. My personal interest is only x86_64 at the moment, but at least I tried to make it useful to the broader community!

Quoted 16 lines
Quoted 12 lines
Quoted 4 lines

[1] The Discoverable Partitions Specification (DPS) Link:
https://uapi-group.org/specifications/specs/
discoverable_partitions_specification/

How are you planning to make this work for parisc?  Some systems have a PALO boot partition (fdisk type 0xf0) but the more modern way is to place palo inside a hidden ext4 inode in /boot.  The way parisc IODC works is very similar to the way MSDOS boots with the palo location table in the first block so I theorize that would probably work for gpt partitions as well ... I'm just not sure anyone has tested it.

Quoted 3 lines

However, to get this to work with PALO for auto discovery, you'd need palo patches to recognize the DPS UUID and no-one seems to have submitted anything to palo for this.

Quoted 8 lines

Maybe it's not necessary that palo does this job?
palo could stay as is and load kernel and the initrd.
Then the kernel (or the scripts in initrd) could try to find the root partition on it's own (and handle GPT discs).

I even once started porting grub to parisc (which is currently on hold because I'm busy with other stuff). If I ever finish it, having such a mechanism/constant already in place is IMHO beneficial.

You can see my answer to Alexander on the cover letter. This was an oversight. parisc does not have CONFIG_EFI to begin with, so the feature is just dead code there.

I will remove parisc (and all other architectures which do not have a CONFIG_EFI) in v2. If someone wants to implement EFI support those architectures, only then, we can revisit this DPS topic for these architectures.

Yours sincerely,
Vincent Mailhol

#20 lore raw

Re: [PATCH 12/19] x86: define DPS root partition type UUIDs

In reply to Vincent Mailhol

On 6/15/26 13:19, Vincent Mailhol wrote:
...

Quoted 6 lines

That said, your points make sense to me, and I would be supportive to allow a search for a secondary UUID as a kernel extension. If we do so, I think the only constraint should be to make sure that we check for the exact match first (e.g. check x86_64 type before x86_32 type).

Would that make sense?

Yep, that makes sense to me.

Quoted 23 lines
Quoted 1 line

2. Should the UUIDs be defined in arch code or generic code?

I think that you convinced me to put it in generic code.

Quoted 1 line

3. Kconfig or #ifdefs?

I would say Kconfig. If we go for the exact match only, that would be:

CONFIG_DPS_ROOT_PARTITION_TYPE_UUID

If we allow more as an extension, that would become:

- CONFIG_DPS_ROOT_PARTITION_TYPE_UUID for the exact match
- CONFIG_DPS_ROOT_PARTITION_TYPE_UUID_SECONDARY for the compatible one.

The drawback is that some entries will be in both:

config DPS_ROOT_PARTITION_TYPE_UUID
string
default "4f68bce3-e8cd-4db1-96e7-fbcaf984b709" if X86_64 default "44479540-f297-41b2-9af7-d131d5f0458a" if X86

Quoted 5 lines
  config DPS_ROOT_PARTITION_TYPE_UUID_SECONDARY
  	string
  	  default "44479540-f297-41b2-9af7-d131d5f0458a" if X86_64 && COMPAT_32

And I don't think we need more than two.

That's not ideal, but it's also a completely static thing that will get written very, very rarely.

Quoted 5 lines

A bonus question: should those Kconfig entries be hidden? I prefer the hidden option because it doesn't add that much code and I thought this was not worth bothering the user with one more menuconfig question. But I would be happy to change if people this this is worth an menuconfig entry.

Yeah, it should be hidden. Anybody that wants to change it for whatever reason can edit the .config file or hack Kconfig.

#30 lore raw
In reply to Vincent Mailhol
Quoted 8 lines · Vincent Mailhol

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.

Quoted 8 lines

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 this discovery feature directly into the kernel so that people who are not using systemd or not using an initrd can still benefit from it. The implementation follows the same model as systemd-gpt-auto-generator:

I happen to co-maintain the DPS. It is userspace policy and complex userspace policy at that and does not belong into the kernel.

This also implements a really tiny portion of the spec. It deals with a lot more complex concepts such as automatic partitioning during installation, verity, LUKS, containers. This is really not intended for the kernel at all. I mean, it's great that this spec is being used but I do not want this in the kernel just for the sake of auto-discovery.

The DPS is completely generic and can be implemented by tooling other than systemd (util-linux implements it and so does refind iirc). I think not wanting to use or build alternative userspace tooling for this is a really weak argument for pushing this into the kernel.

#31 lore raw
Quoted 18 lines · Christian Brauner
Quoted 8 lines · Vincent Mailhol

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.

Quoted 8 lines

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 this discovery feature directly into the kernel so that people who are not using systemd or not using an initrd can still benefit from it. The implementation follows the same model as systemd-gpt-auto-generator:

Quoted 8 lines

I happen to co-maintain the DPS. It is userspace policy and complex userspace policy at that and does not belong into the kernel.

This also implements a really tiny portion of the spec. It deals with a lot more complex concepts such as automatic partitioning during installation, verity, LUKS, containers. This is really not intended for the kernel at all. I mean, it's great that this spec is being used but I do not want this in the kernel just for the sake of auto-discovery.

The implementation of a tiny portion is voluntary. If I can draw a parallel, it would be the same as saying that the root= cmdline option is a tiny portion of what an fstab can do.

Yes it does not manage the LUKS, containers and so on, the same way it is not possible to directly boot those things directly from the kernel.

So, I don't think this conflicts with the actual userland implementations, the same way you can add root= to your command line and still have an initrd next to it.

I did not intend to write this as a replacement but just as a complement to fill the gap of kernel with no initrd.

Quoted 4 lines

The DPS is completely generic and can be implemented by tooling other than systemd (util-linux implements it and so does refind iirc). I think not wanting to use or build alternative userspace tooling for this is a really weak argument for pushing this into the kernel.

Well, I might explain to you where I come from. Time to time, I mess up my configuration. When this issue is in a userland config file (e.g. bad fstab), the recovery is always easy.

But when I mess up the bootloader firmware configuration (e.g. grub, u-boot, edk2), the fix is always painful. I have to fight with a shell with which I am not familiar with to figure out what the correct configuration is.

And an initrd would help but:

- it is still one more file to look for pass as a parameter
- on some machine I do not have one anyway

I think it would have been very neet to have a method to boot a kernel with zero config (understand here: no cmdline, no initrd) and I find out that DPS could achieve that if just a tiny part of it were implemented in the kernel.

For example, in edk2, I would be able to just browse the disk from the "Boot from file" menu and select a kernel. Currently it panics because no configuration is attached. With DPS, we could have it boot linux from that menu. All in a graphical interface, with just up/down arrows and one enter keypress.

And this is my motivation. This non LUKS root read-only part of the DPS is the only piece which makes sense for me in the kernel. Not that I don't *want* to implement it in userland, but just that it doesn't achieve what would be helpful to me (and I guess others).

I thought I wouldn't be the only one in the world to see value in that this is why I posted it.

Yours sincerely,
Vincent Mailhol