From d5c784033e1b4980b614fd34ad7f7881478d376a Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Tue, 6 Jan 2026 16:16:04 -0500 Subject: [PATCH] Add serial numbers to drive details output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changes: - Added SERIAL column to SATA/SAS drive details table - Added SERIAL column to NVMe drive details table - Updated get_drive_smart_info() to extract and return serial numbers - Widened output format to accommodate serial numbers - NVMe serials now display correctly from nvme list output This makes it much easier to match drives to their physical locations by comparing visible serial numbers on drive labels with the output. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- driveAtlas.sh | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/driveAtlas.sh b/driveAtlas.sh index ae2e585..a9bccb8 100644 --- a/driveAtlas.sh +++ b/driveAtlas.sh @@ -175,8 +175,9 @@ get_drive_smart_info() { local type=$(echo "$smart_info" | grep "Rotation Rate" | grep -q "Solid State" && echo "SSD" || echo "HDD") local health=$(echo "$smart_info" | grep "SMART overall-health" | grep -q "PASSED" && echo "✓" || echo "✗") local model=$(echo "$smart_info" | grep "Device Model\|Model Number" | cut -d: -f2 | xargs) + local serial=$(echo "$smart_info" | grep "Serial Number" | awk '{print $3}') - echo "$type|$temp°C|$health|$model" + echo "$type|$temp°C|$health|$model|$serial" } #------------------------------------------------------------------------------ @@ -211,16 +212,16 @@ esac #------------------------------------------------------------------------------ echo -e "\n=== Drive Details with SMART Status ===" -printf "%-15s %-10s %-8s %-8s %-8s %-30s\n" "DEVICE" "SIZE" "TYPE" "TEMP" "HEALTH" "MODEL" -echo "--------------------------------------------------------------------------------" +printf "%-15s %-10s %-8s %-8s %-8s %-30s %-20s\n" "DEVICE" "SIZE" "TYPE" "TEMP" "HEALTH" "MODEL" "SERIAL" +echo "----------------------------------------------------------------------------------------------------------------------------" # SATA/SAS drives lsblk -d -o NAME | grep -v "nvme" | grep -v "rbd" | grep -v "loop" | grep -v "NAME" | while read device; do if [ -b "/dev/$device" ]; then size=$(lsblk -d -n -o SIZE "/dev/$device" 2>/dev/null) smart_info=$(get_drive_smart_info "$device") - IFS='|' read -r type temp health model <<< "$smart_info" - printf "%-15s %-10s %-8s %-8s %-8s %-30s\n" "/dev/$device" "$size" "$type" "$temp" "$health" "$model" + IFS='|' read -r type temp health model serial <<< "$smart_info" + printf "%-15s %-10s %-8s %-8s %-8s %-30s %-20s\n" "/dev/$device" "$size" "$type" "$temp" "$health" "$model" "$serial" fi done @@ -229,9 +230,9 @@ if command -v nvme >/dev/null 2>&1; then nvme_drives=$(sudo nvme list 2>/dev/null | grep "^/dev") if [ -n "$nvme_drives" ]; then echo -e "\n=== NVMe Drives ===" - printf "%-15s %-10s %-10s %-40s\n" "DEVICE" "SIZE" "TYPE" "MODEL" - echo "--------------------------------------------------------------------------------" - echo "$nvme_drives" | awk '{printf "%-15s %-10s %-10s %-40s\n", $1, $6, "NVMe", $3}' + printf "%-15s %-10s %-10s %-40s %-20s\n" "DEVICE" "SIZE" "TYPE" "MODEL" "SERIAL" + echo "----------------------------------------------------------------------------------------------------------------------------" + echo "$nvme_drives" | awk '{printf "%-15s %-10s %-10s %-40s %-20s\n", $1, $6, "NVMe", $3, $2}' fi fi