Ops Did I just Commit That?

It hummed too long in restless loops, a tireless heart with no retreat. But now, aligned, its rhythm stills— the work is done, it sinks to sleep.

I have a WD MyBook attached via USB to my Raspberry Pi 5. It never seemed to spin down automatically, even though I only access it intermittently for backups, I always assumed it did that as it did so when connecting to my NAS. So went on to scouring the net knew it has to be a software issue. downloaded hdparm and then checking the drive state with hdparm -C /dev/sda. it found the drive but threw SCSI sense data warnings and showing the drive as “unknown”. so gpt time it was, I needed a reliable way to force and automate its standby/spindown.

1. Hdparm Install & Basic Checks

  • Installed hdparm:
    sudo apt-get update
    sudo apt-get install hdparm
    
  • Checked /sys/block/sda/device/state and other sysfs entries, but they remained running.
  • Ran hdparm -C /dev/sda, which returned “bad/missing sense data” messages and “unknown” drive state, likely from the USB-SATA bridge.

2. Verifying Background Activity

  • Ensured no logs, indexing, or swap were on /dev/sda.
  • Confirmed no processes were writing periodically to the drive by monitoring disk access or using iostat/iotop.
  • Concluded it was likely just ignoring or partially implementing some hdparm commands.

3. Forcing Spindown

  • Tested an immediate spindown:
    sudo hdparm -y /dev/sda
    
  • Despite the same SCSI sense error, the drive physically spun down. Verified with:
    sudo smartctl -n standby -i /dev/sda
    
    which reported Device is in STANDBY mode.

4. Setting Automatic Spindown

  • Applied an idle timer:
    # 15 minute timer.
    sudo hdparm -S 180 /dev/sda
    
    which, in theory, should spin down after 15 minutes of inactivity.
  • Edited /etc/hdparm.conf to persist:
    /dev/sda {
      spindown_time = 180
    }
    
  • Confirmed that after ~15 minutes, the drive entered standby (though still gave sense-data warnings in logs).

5. Optional: Using hd-idle Instead

If hdparm -S does not work reliably or the drive keeps ignoring it, hd-idle is a good alternative:

  1. Install:
    sudo apt-get update
    sudo apt-get install hd-idle
    
  2. Configure /etc/default/hd-idle or /etc/hd-idle.conf:
    HD_IDLE_OPTS="-i 0 -a /dev/sda -i 900"
    
    This tells the daemon to spin down /dev/sda after 900 seconds (15 minutes) of no I/O.
  3. Enable and start:
    sudo systemctl enable hd-idle
    sudo systemctl start hd-idle
    
  4. Difference vs. hdparm:
    • hdparm -S sets an internal drive firmware timeout (if the enclosure respects it). Once configured, no extra process is needed.
    • hd-idle is a user-space daemon that watches for inactivity and manually sends the “spin down” command. It’s great when the enclosure ignores the built-in spindown timer.
    • hd-idle in a sense is a app you always need running for this so hdparam is a better option if possible.

hdparm worked once we forced it with hdparm -y, and then setting hdparm -S in /etc/hdparm.conf for an automatic spindown was sufficient. If that had failed, switching to hd-idle would have been the next step. In both cases, background processes or frequent accesses can keep the drive awake, so ensuring no unwanted writes or SMART polling is crucial.

Recap spindown cheat‑sheet

StepCommands / ConfigOutcome / Notes
1 Basic checkshdparm -C /dev/sda; inspect /sys/block/sda/device/stateUSB‑SATA bridge reports “bad/missing sense data”, drive state stays running
2 Verify background activityCheck disk I/O with iostat, iotop; be sure logs/indexing/swap aren’t on /dev/sdaBridge appears to ignore or only partly honor some hdparm commands
3 Force immediate spindownhdparm -y /dev/sda; verify with smartctl -n standby -i /dev/sdaDrive spins down; SMART shows Device is in STANDBY
4 Set automatic spindownhdparm -S 180 /dev/sda; in /etc/hdparm.conf: /dev/sda { spindown_time = 180 }After ≈15 min idle the drive enters standby (still logs sense‑data warnings)
5 Use hd‑idle (fallback)Install: apt-get install hd-idle; config in /etc/hd-idle.conf: HD_IDLE_OPTS="-i 0 -a /dev/sda -i 900"; then systemctl enable hd-idle && sudo systemctl start hd-idlehd‑idle daemon spins disk down after 900 s (15 min) when the firmware timer is ignored

hdparm vs. hd‑idle

  • hdparm -S sets a firmware‑level timeout; no extra process needed once it’s written.
  • hd-idle is a user‑space daemon monitoring activity and manually issuing the spin‑down; ideal when the enclosure ignores -S.
  • Because hd‑idle must stay running, hdparm is preferable if the bridge honors the timer.

Bottom line: hdparm -y proved the bridge accepts a spin‑down command. Persisting hdparm -S 180 in /etc/hdparm.conf was sufficient. If that fails, switch to hd‑idle. In both cases, make sure nothing (logs, indexing, swap, aggressive SMART polling) keeps the drive awake.



Buy Me a Coffee