Skip to content

Commit

Permalink
add GPT integrity check for amd64 (#4576)
Browse files Browse the repository at this point in the history
  • Loading branch information
openoms committed May 17, 2024
1 parent e63326b commit bf9dbc0
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions home.admin/_bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bf9dbc0

Please sign in to comment.