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/
This commit is contained in:
Gauthier Jolly 2025-10-09 12:14:32 +02:00
parent 9172378dae
commit ddff3faba3
3 changed files with 48 additions and 3 deletions

View File

@ -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 <arch>"
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}"
}

View File

@ -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
}

View File

@ -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}" \