wic: add GPT partition names to partitions

A filesystem label (/dev/disk/by-label) is a property of, and stored in, the
filesystem itself. Partitions that are not destined to hold filesystems are
not formatted, therefore it is not possible to assign filesystem labels to
such partitions.

However, if GPT partitioning is being used, GPT supports the notion of
assigning labels/names to the partitions which are stored as part of the GPT
partition table itself (instead of being stored in the filesystem in the
partition). The naming is a bit confusing (different tools use different
names) but `wic` calls this "--part-name", `lsblk` calls this "PARTLABEL", and
`parted` calls this "name".

In Linux user-space these partition labels are referenced via
/dev/disk/by-partlabel and provide an excellent way of finding these GPT
partitions regardless of which backing device is actually being used (e.g.
mmcblk0, mmcblk1... i.e. emmc, sdcard...).

An example where this would be handy is for interacting with a stored U-Boot
environment. Another potential use would be to use one of the unused raw
partitions to store information such as MAC addresses, serial numbers, etc.
which could be set/updated "at the factory" as images are flashed.

Tested with both systemd and sysvinit on both rock-pi-e and rock-pi-s.

Reviewed-by: Quentin Schulz <quentin.schulz@theobroma-systems.com>
Signed-off-by: Trevor Woerner <twoerner@gmail.com>
This commit is contained in:
Trevor Woerner 2024-04-16 20:31:07 -04:00
parent 0fe7d9c64e
commit 88f2064ca2

View File

@ -18,14 +18,14 @@
# atf 24576 8192 (trusted OS e.g. ATF, OP-TEE, etc)
# root 32768 -
part loader1 --offset 64s --fixed-size 3552K --fstype=none --source rawcopy --sourceparams="file=${SPL_BINARY}"
part v_storage --offset 7168s --fixed-size 256K --fstype=none
part reserved --offset 7680s --fixed-size 192K --fstype=none
part reserved1 --offset 8064s --fixed-size 32K --fstype=none
part uboot_env --offset 8128s --fixed-size 32K --fstype=none
part reserved2 --offset 8192s --fixed-size 4096K --fstype=none
part loader2 --offset 16384s --fixed-size 4096K --fstype=none --source rawcopy --sourceparams="file=u-boot.${UBOOT_SUFFIX}"
part atf --offset 24576s --fixed-size 4096K --fstype=none
part / --label root --active --fstype=ext4 --source rootfs
part loader1 --offset 64s --fixed-size 3552K --fstype=none --part-name loader1 --source rawcopy --sourceparams="file=${SPL_BINARY}"
part v_storage --offset 7168s --fixed-size 256K --fstype=none --part-name v_storage
part reserved --offset 7680s --fixed-size 192K --fstype=none --part-name reserved
part reserved1 --offset 8064s --fixed-size 32K --fstype=none --part-name reserved1
part uboot_env --offset 8128s --fixed-size 32K --fstype=none --part-name uboot_env
part reserved2 --offset 8192s --fixed-size 4096K --fstype=none --part-name reserved2
part loader2 --offset 16384s --fixed-size 4096K --fstype=none --part-name loader2 --source rawcopy --sourceparams="file=u-boot.${UBOOT_SUFFIX}"
part atf --offset 24576s --fixed-size 4096K --fstype=none --part-name atf
part / --label root --active --fstype=ext4 --part-name root --source rootfs
bootloader --ptable gpt