From 2b9871d887b4c2665f30303c726add5f1196c6fa Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Thu, 5 Feb 2026 20:02:25 -0500 Subject: [PATCH] Fix HDD/SSD detection to be more accurate Improved device type detection: - Use anchored regex (^Rotation Rate:) to avoid false matches - Check for actual RPM values (e.g., "7200 rpm") to confirm HDD - Only match SSD in model name field, not anywhere in output - Default to HDD when Rotation Rate field is missing This fixes drives like WDC WD80EFZZ being incorrectly detected as SSDs when the Rotation Rate field wasn't being matched. Co-Authored-By: Claude Opus 4.5 --- driveAtlas.sh | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/driveAtlas.sh b/driveAtlas.sh index 943c8e3..629b391 100644 --- a/driveAtlas.sh +++ b/driveAtlas.sh @@ -751,16 +751,31 @@ parse_smart_data() { fi # Device type detection - handles SSD, HDD, and NVMe + # Priority: 1) NVMe by name, 2) Rotation Rate field, 3) Model name hints, 4) Default HDD if [[ "$device" == nvme* ]]; then type="NVMe" - elif echo "$smart_info" | grep -q "Rotation Rate"; then - if echo "$smart_info" | grep "Rotation Rate" | grep -qiE "solid state|0 rpm"; then + elif echo "$smart_info" | grep -qE "^Rotation Rate:"; then + # Check the Rotation Rate field value + local rotation_rate + rotation_rate="$(echo "$smart_info" | grep -E "^Rotation Rate:" | head -1)" + if echo "$rotation_rate" | grep -qiE "solid state|0 rpm"; then type="SSD" + elif echo "$rotation_rate" | grep -qE "[0-9]+ rpm"; then + # Has actual RPM value (e.g., "7200 rpm") - it's an HDD + type="HDD" else type="HDD" fi - elif echo "$smart_info" | grep -qiE "SSD|Solid State"; then + elif echo "$smart_info" | grep -qE "^Device Model:.*SSD|^Model Number:.*SSD"; then + # Only match SSD in the model name field, not anywhere in output type="SSD" + elif echo "$smart_info" | grep -qE "^Form Factor:.*2\.5"; then + # 2.5" drives without rotation rate specified are likely SSDs + # But large capacity 2.5" could be HDD, so check capacity + type="SSD" + else + # Default to HDD for spinning rust + type="HDD" fi # Health status (basic SMART check)