Fix Rotation Rate regex to handle leading whitespace

The smartctl output has leading whitespace before field names:
  "Rotation Rate:    7200 rpm"

Removed the ^ anchor from the regex so it matches lines with
leading whitespace. This fixes HDD detection for drives that
have proper Rotation Rate fields in their SMART data.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-05 20:07:35 -05:00
parent 51cc739da5
commit e6cc9a3853

View File

@@ -758,24 +758,21 @@ parse_smart_data() {
# Priority: 1) NVMe by name, 2) Rotation Rate field, 3) Model name hints, 4) Default HDD # Priority: 1) NVMe by name, 2) Rotation Rate field, 3) Model name hints, 4) Default HDD
if [[ "$device" == nvme* ]]; then if [[ "$device" == nvme* ]]; then
type="NVMe" type="NVMe"
elif echo "$smart_info" | grep -qE "^Rotation Rate:"; then elif echo "$smart_info" | grep -qE "Rotation Rate:"; then
# Check the Rotation Rate field value # Check the Rotation Rate field value (may have leading whitespace)
local rotation_rate local rotation_rate
rotation_rate="$(echo "$smart_info" | grep -E "^Rotation Rate:" | head -1)" rotation_rate="$(echo "$smart_info" | grep -E "Rotation Rate:" | head -1)"
if echo "$rotation_rate" | grep -qiE "solid state|0 rpm"; then if echo "$rotation_rate" | grep -qiE "solid state"; then
type="SSD" type="SSD"
elif echo "$rotation_rate" | grep -qE "[0-9]+ rpm"; then elif echo "$rotation_rate" | grep -qE "[0-9]+ rpm"; then
# Has actual RPM value (e.g., "7200 rpm") - it's an HDD # Has actual RPM value (e.g., "7200 rpm") - it's an HDD
type="HDD" type="HDD"
else else
# Unknown rotation rate, default to HDD
type="HDD" type="HDD"
fi fi
elif echo "$smart_info" | grep -qE "^Device Model:.*SSD|^Model Number:.*SSD"; 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 # Match SSD in the model name field
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" type="SSD"
else else
# Default to HDD for spinning rust # Default to HDD for spinning rust