Die UUIDs der Partitionen in Variablen eingelesen.

This commit is contained in:
eichehome 2023-07-21 14:16:58 +02:00
parent e8bd40f650
commit 9f7ecfd415

View file

@ -97,29 +97,46 @@ sgdisk -n 0:0:0 -t 0:4f68bce3-e8cd-4db1-96e7-fbcaf984b709 -c 0:"System Root" "${
UUID_ESP=""
UUID_ROOT=""
UUID_USR=""
UUID_USRHASH=""
# Anzahl der Partitionen ermitteln
DRIVE_NAME=${DRIVE//\/dev\/}
declare -i NUMBER_OF_PARTITIONS;
NUMBER_OF_PARTITIONS=$(lsblk | grep -c "${DRIVE_NAME}")
NUMBER_OF_PARTITIONS=$(lsblk | grep -c "${DRIVE_NAME}[0-9]")
declare -i UNKNOWN_PARTITIONS
NOCASEMATCH_UNSET=$(shopt -u | grep -c nocasematch)
if [[ $NOCASEMATCH_UNSET ]]; then
shopt -s nocasematch
fi
for (( i=${NUMBER_OF_PARTITIONS}; ${i} > 0 ; ${i}-- )) ; do
for (( i=${NUMBER_OF_PARTITIONS}; ${i} > 0 ; i=${i}-1 )) ; do
OUTPUT=$(sgdisk -i "${i}" "${DRIVE}")
PARTITION_EXISTS=$(echo "${OUTPUT}" | grep -c "GUID")
if [[ "${PARTITION_EXISTS}" != "0" ]]; then
GUID_CODE=$(echo "${OUTPUT}" | grep "GUID code:" | cut -d ' ' -f 4)
UUID=$(echo "${OUTPUT}" | grep "unique GUID:" | cut -d ' ' -f 4)
case $GUID_CODE in
"8484680c-9521-48c6-9c11-b0720656f69e" ) echo "USR-Partition, UUID: ${UUID} " ;;
'USR_HASH' ) echo "USRHASH-Partition" ;;
"c12a7328-f81f-11d2-ba4b-00a0c93ec93b" ) echo "ESP-Partition, UUID: ${UUID}" ;;
"4f68bce3-e8cd-4db1-96e7-fbcaf984b709" ) echo "Root-Partition, UUID: ${UUID}" ;;
* ) echo "Unbekannte Partition";;
"8484680c-9521-48c6-9c11-b0720656f69e" )
echo "USR-Partition, UUID: ${UUID}"
UUID_USR=${UUID}
;;
"c12a7328-f81f-11d2-ba4b-00a0c93ec93b" )
echo "ESP-Partition, UUID: ${UUID}"
UUID_ESP=${UUID}
;;
"4f68bce3-e8cd-4db1-96e7-fbcaf984b709" )
echo "Root-Partition, UUID: ${UUID}"
UUID_ROOT=${UUID}
;;
"77ff5f63-e7b6-4633-acf4-1565b864c0e6" )
echo "Usrhash-Partition, UUID: ${UUID}"
UUID_USRHASH=${UUID}
;;
* )
echo "Unbekannte Partition"
UNKNOWN_PARTITIONS="${UNKNOWN_PARTITIONS}+1"
;;
esac
else
echo "no partition found"