Created
February 18, 2023 11:40
-
-
Save ngandrass/187d0db66a90ed702a187592367963e8 to your computer and use it in GitHub Desktop.
Map GPTID to disk / device identifier (e.g. ada0)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Create associative mapping array | |
declare -A GPTID_TO_DISKID | |
while read -r row; do | |
gptid=$(echo "$row" | cut -d ' ' -f1) | |
diskid=$(echo "$row" | cut -d ' ' -f3 | rev | cut -d 'p' -f2 | rev) | |
if [[ "$gptid" = "gptid"* ]]; then | |
GPTID_TO_DISKID[$gptid]=$diskid | |
fi | |
done < <(glabel status | tail -n +2 | tr -s ' ') | |
# Verbose logging | |
echo "Detected GPTID to disk identifier mappings:" | |
for gptid in "${!GPTID_TO_DISKID[@]}"; do | |
echo "-> [$gptid]=${GPTID_TO_DISKID[$gptid]}" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment