From ddff3faba3d9d6461a28ef1369b388282775331d Mon Sep 17 00:00:00 2001 From: Gauthier Jolly Date: Thu, 9 Oct 2025 12:14:32 +0200 Subject: [PATCH] cpc/UEFI: set the right partition type for the rootfs To make our disk images more discoverable, we should use the correct partition type for the root filesystem. This aligns with the Discoverable Disk Image (DDI) specification developed by the UAPI group[1] and makes our images more self-describing, e.g. with fdisk, before: Device Start End Sectors Size Type /dev/nbd0p1 2324480 7339998 5015519 2.4G Linux filesystem ... and now after: Device Start End Sectors Size Type /dev/nbd0p1 2324480 7339998 5015519 2.4G Linux root (x86-64) ... [1] https://uapi-group.org/specifications/specs/discoverable_partitions_specification/ --- live-build/functions | 40 +++++++++++++++++++ .../hooks.d/base/disk-image-ppc64el.binary | 4 +- .../hooks.d/base/disk-image-uefi.binary | 7 +++- 3 files changed, 48 insertions(+), 3 deletions(-) diff --git a/live-build/functions b/live-build/functions index a4b27bd0..4a2c57f7 100644 --- a/live-build/functions +++ b/live-build/functions @@ -1404,3 +1404,43 @@ EOF EOF fi } + +# Determine the appropriate partition type UUID for the root filesystem +# based on the architecture. +# Please see https://uapi-group.org/specifications/specs/discoverable_partitions_specification/ +# for where the GUIDs come from. +gpt_root_partition_uuid() { + local ARCH="$1" + + if [ -z "${ARCH:-}" ]; then + echo "usage: gpt_root_partition_uuid " + exit 1 + fi + + case "${ARCH}" in + "amd64") + ROOTFS_PARTITION_TYPE="4f68bce3-e8cd-4db1-96e7-fbcaf984b709" + ;; + "arm64") + ROOTFS_PARTITION_TYPE="b921b045-1df0-41c3-af44-4c6f280d3fae" + ;; + "armhf") + ROOTFS_PARTITION_TYPE="69dad710-2ce4-4e3c-b16c-21a1d49abed3" + ;; + "riscv64") + ROOTFS_PARTITION_TYPE="72ec70a6-cf74-40e6-bd49-4bda08e8f224" + ;; + "ppc64el") + ROOTFS_PARTITION_TYPE="c31c45e6-3f39-412e-80fb-4809c4980599" + ;; + "s390x") + ROOTFS_PARTITION_TYPE="5eead9a9-fe09-4a1e-a1d7-520d00531306" + ;; + *) + echo "Unsupported architecture: ${ARCH}" + exit 1 + ;; + esac + + echo "${ROOTFS_PARTITION_TYPE}" +} \ No newline at end of file diff --git a/live-build/ubuntu-cpc/hooks.d/base/disk-image-ppc64el.binary b/live-build/ubuntu-cpc/hooks.d/base/disk-image-ppc64el.binary index 50fe4522..701b8604 100755 --- a/live-build/ubuntu-cpc/hooks.d/base/disk-image-ppc64el.binary +++ b/live-build/ubuntu-cpc/hooks.d/base/disk-image-ppc64el.binary @@ -24,7 +24,9 @@ create_partitions() { sgdisk "${disk_image}" \ --new=2::+8M \ --new=1: - sgdisk "${disk_image}" -t 2:4100 + sgdisk "${disk_image}" \ + -t 2:4100 \ + -t 1:"$(gpt_root_partition_uuid $ARCH)" sgdisk "${disk_image}" \ --print } diff --git a/live-build/ubuntu-cpc/hooks.d/base/disk-image-uefi.binary b/live-build/ubuntu-cpc/hooks.d/base/disk-image-uefi.binary index fccccb99..cfe8ca3a 100755 --- a/live-build/ubuntu-cpc/hooks.d/base/disk-image-uefi.binary +++ b/live-build/ubuntu-cpc/hooks.d/base/disk-image-uefi.binary @@ -41,7 +41,8 @@ create_partitions() { --typecode=15:ef00 \ --new=13::1G \ --typecode=13:ea00 \ - --new=1: + --new=1: \ + --typecode=1:"$(gpt_root_partition_uuid $ARCH)" ;; riscv64) sgdisk "${disk_image}" \ @@ -51,6 +52,7 @@ create_partitions() { --new=15::+106M \ --typecode=15:ef00 \ --new=1:: \ + --typecode=1:"$(gpt_root_partition_uuid $ARCH)" \ --attributes=1:set:2 ;; amd64) @@ -62,7 +64,8 @@ create_partitions() { --new=1:: sgdisk "${disk_image}" \ -t 14:ef02 \ - -t 15:ef00 + -t 15:ef00 \ + -t 1:"$(gpt_root_partition_uuid $ARCH)" ;; esac sgdisk "${disk_image}" \