From 5d1b0a4be82eca2a8ffc47f60b9b6508654b1cbc Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Thu, 9 Jul 2026 18:31:42 +0000 Subject: [PATCH] armbian_rootenc_setup: improve get_partition_info() --- scripts/armbian_rootenc_setup.sh | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/scripts/armbian_rootenc_setup.sh b/scripts/armbian_rootenc_setup.sh index cc0ff39..e4cfad2 100755 --- a/scripts/armbian_rootenc_setup.sh +++ b/scripts/armbian_rootenc_setup.sh @@ -245,6 +245,7 @@ _set_host_vars() { target_mounts=($BOOT_ROOT $TARGET_ROOT) build_subdirs=($SRC_ROOT $BOOT_ROOT $TARGET_ROOT) src_subdirs=($SRC_ROOT) + boot_partition_sectors=819200 ;; # 400MB } check_sdcard_name_and_params() { @@ -633,22 +634,26 @@ get_armbian_image() { } get_partition_info() { - local cmdout - cmdout=$(fdisk --list --output='Start' $ARMBIAN_IMAGE) - partition_table_type=$(echo "$cmdout" | grep '^Disklabel' | cut --delimiter=' ' --fields=3) + # global: partition_type_uuid start_sector + local uuid end_sector sectors name + partition_table_type=$(fdisk --list $ARMBIAN_IMAGE | grep '^Disklabel' | sed -r 's/.*\s+//') case $partition_table_type in 'gpt') - cmdout=$(fdisk --list-details --output='Start,Type-UUID' $ARMBIAN_IMAGE) - read start_sector partition_type_uuid <<<$(echo "$cmdout" | tail --lines=1) + disk_id=$(fdisk --list $ARMBIAN_IMAGE | grep '^Disk identifier' | sed -r 's/.*\s+//') + part_info=$( + fdisk --list-details --output='Type-UUID,UUID,Start,End,Sectors,Name' \ + $ARMBIAN_IMAGE | egrep '^\S{8}-\S{4}-\S{4}-\S{4}-\S{12}\s') + read partition_type_uuid uuid start_sector end_sector sectors name <<<$( + echo "$part_info" | head --lines=1) ;; 'dos') - read start_sector <<<$(echo "$cmdout" | tail --lines=1) + part_info="$(fdisk --list-details --output='Start' $ARMBIAN_IMAGE | egrep '^\s*[0-9]+$')" + read start_sector <<<$(echo "$part_info" | head --lines=1) ;; *) die "$partition_table_type: unrecognized partition table type!" ;; esac [ $((start_sector % 8)) -eq 0 ] || die "start sector: $start_sector: first partition misaligned!" - boot_partition_sectors=819200 # 400MB gmsg "Partition table: $PURPLE${partition_table_type^^}$RESET" }