Skip to contentSkip to conversation

wic: add GPT partition names to partitions

PATCH Applied Trevor Woerner 2 participants 3 messages Apr 18, 2024 – Apr 22, 2024 Arm Rockchip

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 wic/rockchip.wks | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
wic/rockchip.wks +9 -9
index a9e5508d3ff5..9ba3352b51bb 100644
@@ -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
Signature · 1 line
2.44.0.478.g7774cfed6261
Reviewed-by on v1 1/1
#1 lore raw

Hi Trevor,

Quoted 17 lines · Trevor Woerner via lists.yoctoproject.org

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...).

Quoted 8 lines

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.

Thanks,
Quentin

author Applied
#2 lore raw
In reply to Trevor Woerner
Quoted 22 lines · Trevor Woerner

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.

Quoted 6 lines

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

---
 wic/rockchip.wks | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

Applied to meta-rockchip, master branch.