added better disk checking

This commit is contained in:
2025-12-13 21:20:06 -08:00
parent a552849eb2
commit 9dfc39c9d8

View File

@@ -7,14 +7,36 @@ echo "==== 🧠 SD Card Disk Imager + Auto Resize ===="
# === Step 1: Detect likely SD card devices ===
echo ""
echo "📦 Scanning for removable storage devices..."
mapfile -t DISKS < <(lsblk -dpno NAME,MODEL,SIZE,RM | awk '$4 == 1 { print $1 }')
echo "📦 Scanning for removable / USB storage devices..."
echo "📦 Scanning for removable / USB storage devices..."
mapfile -t DISKS < <(
lsblk -dpno NAME,RM,TRAN | awk '
{
name=$1
rm=$2
tran=$3
# Select:
# - anything marked removable (RM=1)
# - OR anything on USB transport
if (rm == "1" || tran == "usb") {
print name
}
}
'
)
if [ ${#DISKS[@]} -eq 0 ]; then
echo "❌ No removable (likely SD card) devices found!"
echo "❌ No likely SD/USB storage devices found!"
echo " (Debug: run `lsblk -dpno NAME,MODEL,SIZE,RM,ROTA,TRAN` manually to inspect.)"
exit 1
fi
echo ""
echo "📂 Found the following removable block devices:"
for i in "${!DISKS[@]}"; do