From 58eccc839b67c97026f5d2a5347de8a7ed4d9a03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20=C4=8Cerm=C3=A1k?= Date: Thu, 21 Nov 2024 14:55:20 +0100 Subject: [PATCH] Always use NVMe datadisk on Yellow if it's present on first boot If HAOS on Yellow is booted for the first time with NVMe data disk present, it should be preferred over the empty eMMC data partition. This will ease reinstall of the system and migration from CM4 to CM5. All other data disks (e.g. if a USB drive is used for them) are still treated as before, requiring manual adoption using the Supervisor repair. --- .../usr/libexec/haos-data-disk-detach | 62 +++++++++++++++---- 1 file changed, 50 insertions(+), 12 deletions(-) diff --git a/buildroot-external/rootfs-overlay/usr/libexec/haos-data-disk-detach b/buildroot-external/rootfs-overlay/usr/libexec/haos-data-disk-detach index 361a6745e89..92472cd686e 100755 --- a/buildroot-external/rootfs-overlay/usr/libexec/haos-data-disk-detach +++ b/buildroot-external/rootfs-overlay/usr/libexec/haos-data-disk-detach @@ -9,15 +9,53 @@ sleep 10s datapartitions=$(blkid --match-token LABEL="hassos-data" --output device) -for datapart in ${datapartitions} -do - datadev=$(lsblk -no pkname "${datapart}") - - # If major does not match our root device major, it is an external data - # disk. Rename to make sure it gets ignored. - if [ "$rootdev" != "$datadev" ] - then - echo "Found external data disk device on ${datapart}, mark it disabled..." - e2label "${datapart}" hassos-data-dis - fi -done +. /etc/os-release + +disable_data_partition() { + e2label "${1}" hassos-data-dis +} + +if [ "$VARIANT_ID" = "yellow" ]; then + emmc_data_partition="" + nvme_data_partition="" + + for datapart in ${datapartitions}; do + datadev=$(lsblk -no pkname "${datapart}") + + case "${datadev}" in + mmc*) + # Data partition on internal eMMC + if [ "$rootdev" = "$datadev" ]; then + emmc_data_partition="${datapart}" + fi + ;; + nvme0*) + # Data partition on first NVMe disk + nvme_data_partition="${datapart}" + ;; + *) + # Disable all other data disks as normally + if [ "$rootdev" != "$datadev" ]; then + echo "Found extra external data disk device on ${datapart}, marking it disabled..." + disable_data_partition "${datapart}" + fi + ;; + esac + done + + if [ -n "${emmc_data_partition}" ] && [ -n "${nvme_data_partition}" ]; then + echo "Found both eMMC and NVMe data disk devices, marking eMMC as disabled" + disable_data_partition "${emmc_data_partition}" + fi +else + for datapart in ${datapartitions}; do + datadev=$(lsblk -no pkname "${datapart}") + + # If major does not match our root device major, it is an external data + # disk. Rename to make sure it gets ignored. + if [ "$rootdev" != "$datadev" ]; then + echo "Found external data disk device on ${datapart}, marking it disabled..." + disable_data_partition "${datapart}" + fi + done +fi