diff --git a/home.admin/_bootstrap.sh b/home.admin/_bootstrap.sh index f848d471e..eecea58ad 100755 --- a/home.admin/_bootstrap.sh +++ b/home.admin/_bootstrap.sh @@ -337,6 +337,34 @@ else echo "No HDMI switch found. " >> $logFile 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 # extend sd card to maximum capacity