optimiere die Erkennung der Bootpartition in blitz.data.sh

This commit is contained in:
rootzoll
2025-01-19 00:09:08 +01:00
parent 625f664ea7
commit 8fdfa6c777

View File

@@ -927,10 +927,12 @@ if [ "$1" = "kill-boot" ]; then
# get boot partition by checking filesystem type and flags
bootPartition=""
for part in $(lsblk -no NAME "/dev/${device}" | grep "^${device}p\?[0-9]"); do
if blkid "/dev/${part}" | grep -q "TYPE=\"vfat\"" && \
parted "/dev/${device}" print | grep "^ *[0-9]" | grep -q "boot\|esp"; then
bootPartition="${part}"
partitionNumber=""
for partNumber in $(parted -s "/dev/${device}" print | grep "^ *[0-9]" | awk '{print $1}'); do
if blkid "/dev/${device}${partNumber}" | grep -q "TYPE=\"vfat\"" && \
parted "/dev/${device}" print | grep "^ *${partNumber}" | grep -q "boot\|esp"; then
bootPartition="${device}${partNumber}"
partitionNumber="${partNumber}"
break
fi
done
@@ -946,13 +948,6 @@ if [ "$1" = "kill-boot" ]; then
exit 1
fi
# get partition number from device name
partitionNumber=$(echo "${bootPartition}" | grep -o '[0-9]*$')
if [ "${partitionNumber}" = "" ]; then
echo "error='partition number not found'"
exit 1
fi
# make sure boot partition is not mounted
echo "# unmounting boot partition (${bootPartition}) (${partitionNumber})"
exit 1