Show NVMe drives with bay mappings in main table
NVMe drives mapped to m2-1, m2-2 slots now appear in the main drive table with their bay position, instead of in a separate unmapped section. - Extended bay loop to include m2-* slots after numeric bays - NVMe section now only shows truly unmapped NVMe drives - Mapped NVMe drives show full SMART data like other drives Fixes: #5 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -460,8 +460,10 @@ for bay in "${!DRIVE_MAP[@]}"; do
|
||||
fi
|
||||
done
|
||||
|
||||
# Sort drives by bay position
|
||||
for bay in $(printf '%s\n' "${!DRIVE_MAP[@]}" | grep -E '^[0-9]+$' | sort -n); do
|
||||
# Sort drives by bay position (numeric bays first, then m2 slots)
|
||||
# Combine numeric bays (sorted numerically) with m2 slots (sorted alphanumerically)
|
||||
all_bays=$(printf '%s\n' "${!DRIVE_MAP[@]}" | grep -E '^[0-9]+$' | sort -n; printf '%s\n' "${!DRIVE_MAP[@]}" | grep -E '^m2-' | sort)
|
||||
for bay in $all_bays; do
|
||||
device="${DRIVE_MAP[$bay]}"
|
||||
if [[ -n "$device" && "$device" != "EMPTY" && -b "/dev/$device" ]]; then
|
||||
size=$(lsblk -d -n -o SIZE "/dev/$device" 2>/dev/null)
|
||||
@@ -513,22 +515,33 @@ for bay in $(printf '%s\n' "${!DRIVE_MAP[@]}" | grep -E '^[0-9]+$' | sort -n); d
|
||||
fi
|
||||
done
|
||||
|
||||
# NVMe drives
|
||||
# NVMe drives (only show unmapped ones - mapped NVMe drives appear in main table)
|
||||
nvme_devices=$(lsblk -d -n -o NAME,SIZE | grep "^nvme" 2>/dev/null)
|
||||
if [ -n "$nvme_devices" ]; then
|
||||
echo -e "\n=== NVMe Drives ==="
|
||||
printf "%-15s %-10s %-10s %-40s %-25s\n" "DEVICE" "SIZE" "TYPE" "MODEL" "SERIAL"
|
||||
echo "------------------------------------------------------------------------------------------------------"
|
||||
echo "$nvme_devices" | while read -r name size; do
|
||||
device="/dev/$name"
|
||||
# Get model and serial from smartctl for accuracy
|
||||
smart_info=$(sudo smartctl -i "$device" 2>/dev/null)
|
||||
model=$(echo "$smart_info" | grep "Model Number" | cut -d: -f2 | xargs)
|
||||
serial=$(echo "$smart_info" | grep "Serial Number" | cut -d: -f2 | xargs)
|
||||
[[ -z "$model" ]] && model="-"
|
||||
[[ -z "$serial" ]] && serial="-"
|
||||
printf "%-15s %-10s %-10s %-40s %-25s\n" "$device" "$size" "NVMe" "$model" "$serial"
|
||||
done
|
||||
if [[ -n "$nvme_devices" ]]; then
|
||||
# Filter out already-mapped NVMe devices
|
||||
unmapped_nvme=""
|
||||
while read -r name size; do
|
||||
if [[ -z "${DEVICE_TO_BAY[$name]:-}" ]]; then
|
||||
unmapped_nvme+="$name $size"$'\n'
|
||||
fi
|
||||
done <<< "$nvme_devices"
|
||||
|
||||
if [[ -n "$unmapped_nvme" ]]; then
|
||||
printf "\n=== Unmapped NVMe Drives ===\n"
|
||||
printf "%-15s %-10s %-10s %-40s %-25s\n" "DEVICE" "SIZE" "TYPE" "MODEL" "SERIAL"
|
||||
echo "------------------------------------------------------------------------------------------------------"
|
||||
echo "$unmapped_nvme" | while read -r name size; do
|
||||
[[ -z "$name" ]] && continue
|
||||
device="/dev/$name"
|
||||
# Get model and serial from smartctl for accuracy
|
||||
smart_info="$(sudo smartctl -i "$device" 2>/dev/null)"
|
||||
model="$(echo "$smart_info" | grep "Model Number" | cut -d: -f2 | xargs)"
|
||||
serial="$(echo "$smart_info" | grep "Serial Number" | cut -d: -f2 | xargs)"
|
||||
[[ -z "$model" ]] && model="-"
|
||||
[[ -z "$serial" ]] && serial="-"
|
||||
printf "%-15s %-10s %-10s %-40s %-25s\n" "$device" "$size" "NVMe" "$model" "$serial"
|
||||
done
|
||||
fi
|
||||
fi
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user