add GPT integrity check for amd64 (#4576)

This commit is contained in:
openoms 2024-05-17 09:55:01 +02:00 committed by GitHub
parent e63326bbea
commit bf9dbc0321
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -337,6 +337,34 @@ else
echo "No HDMI switch found. " >> $logFile echo "No HDMI switch found. " >> $logFile
fi fi
################################
# GPT integrity check
################################
check_and_fix_gpt() {
local device=$1
output=$(sudo gdisk -l $device 2>&1)
if echo "$output" | grep -q "PMBR size mismatch"; then
echo "GPT PMBR size mismatch detected on $device. Fixing..." >> $logFile
sgdisk -e $device
echo "Fixed GPT PMBR size mismatch on $device." >> $logFile
elif echo "$output" | grep -q "The backup GPT table is not on the end of the device"; then
echo "Backup GPT table is not at the end of $device. Fixing..." >> $logFile
sgdisk -e $device
echo "Fixed backup GPT table location on $device." >> $logFile
else
echo "No GPT issues detected on $device." >> $logFile
fi
}
# List all block devices
devices=$(lsblk -dno NAME | grep -E '^sd|^nvme|^vd|^mmcblk')
# Check and fix each device
for dev in $devices; do
check_and_fix_gpt /dev/$dev
done
################################ ################################
# FS EXPAND # FS EXPAND
# extend sd card to maximum capacity # extend sd card to maximum capacity