diff --git a/packages/bsp/common/usr/bin/armbian-install b/packages/bsp/common/usr/bin/armbian-install index 6f264d343149..799b137a2e01 100755 --- a/packages/bsp/common/usr/bin/armbian-install +++ b/packages/bsp/common/usr/bin/armbian-install @@ -57,7 +57,7 @@ root_partition_device=/dev/$root_partition_device_name # find targets: legacy SUNXI NAND, EMMC, SATA, NVMe, MTD block and/or MTD char driven flash [[ -b /dev/nand ]] && nandcheck=$(ls -d -1 /dev/nand* | grep -w 'nand' | awk '{print $NF}'); emmccheck=$(ls -d -1 /dev/mmcblk* 2>/dev/null | grep -w 'mmcblk[0-9]' | grep -v "$root_partition_device"); -diskcheck=$(lsblk -l | awk -F" " '/ disk / {print $1}' | grep -E '^sd|^nvme|^mmc' | grep -v "$root_partition_device_name" | grep -v boot) +diskcheck=$(lsblk -Al | awk -F" " '/ disk / {print $1}' | grep -E '^sd|^nvme|^mmc' | grep -v "$root_partition_device_name" | grep -v boot) # Start mtdcheck with probable MTD block device partitions: mtdcheck=$(grep 'mtdblock' /proc/partitions | awk '{print $NF}' | xargs) # Append mtdcheck with probable MTD char devices filtered for partition name(s) @@ -669,6 +669,8 @@ check_partitions() CMD="lsblk -io KNAME,FSTYPE,SIZE,TYPE,MOUNTPOINT | grep -v -w $root_partition_name $INCLUDE $EXCLUDE | grep -E '^sd|^nvme|^md|^mmc' | awk -F\" \" '/ part | raid..? / {print \$1}'" AvailablePartitions=$(eval $CMD) + FREE_SPACE=$(sfdisk --list-free /dev/$diskcheck | grep G | tail -1 | awk '{print $4}' | sed "s/G//") + dialog --yes-label "Proceed" --no-label 'Skip' --title "$title" --backtitle "$backtitle" --yesno "\nIt is highly recommended to wipe all partitions on the destination disk\n \n/dev/$diskcheck\n\nand leave installer to make them!" 10 75 # wiping destination to make sure we don't run into issues @@ -680,13 +682,16 @@ check_partitions() if [[ "${ACKNOWLEDGEMENT}" == "Yes, I understand" ]]; then dd if=/dev/zero of=/dev/${diskcheck} bs=1M count=10 >> $logfile 2>&1 partprobe -s "/dev/${diskcheck}" >> $logfile 2>&1 - echo -e 'mktable gpt\nmkpart primary ext4 0% 100%\nquit' | sudo parted "/dev/${diskcheck}" >> $logfile 2>&1 - sudo partprobe -s "/dev/${diskcheck}" >> $logfile 2>&1 - sleep 2 + # only make one ext4 partition if we don't have UEFI + if [[ "$DEVICE_TYPE" != uefi ]]; then + echo -e 'mktable gpt\nmkpart primary ext4 0% 100%\nquit' | sudo parted "/dev/${diskcheck}" >> $logfile 2>&1 + sudo partprobe -s "/dev/${diskcheck}" >> $logfile 2>&1 + sleep 2 + fi fi fi - if [[ -z $AvailablePartitions ]]; then + if [[ -z $AvailablePartitions ]] || [[ "${FREE_SPACE%.*}" -gt 4 ]]; then # Consider brand new devices or devices with a wiped partition table if [[ -z $(blkid /dev/$diskcheck) ]]; then # There is not yet any partition table on the disk device. @@ -736,7 +741,7 @@ check_partitions() } | fdisk /dev/$diskcheck &> /dev/null || true fi fi - CMD="lsblk -io KNAME,FSTYPE,SIZE,TYPE,MOUNTPOINT | grep -v -w $root_partition_name $INCLUDE $EXCLUDE | grep -E '^sd|^nvme|^md|^mmc' | awk -F\" \" '/ part | raid..? / {print \$1}' | uniq | sed 's|^|/dev/|' | nl | xargs echo -n" + CMD="lsblk -io KNAME,FSTYPE,SIZE,TYPE,MOUNTPOINT,PARTTYPENAME | grep -v -w $root_partition_name $INCLUDE $EXCLUDE | grep Linux | grep -E '^sd|^nvme|^md|^mmc' | awk -F\" \" '/ part | raid..? / {print \$1}' | uniq | sed 's|^|/dev/|' | nl | xargs echo -n" partprobe AvailablePartitions=$(eval $CMD) PartitionOptions=($AvailablePartitions)