[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Hard disks auto-spinning-down





On 9/29/19 4:30 AM, Mark Fletcher wrote:
Any thoughts on where I might look to find settings that can be tweaked
to make it spin down when idle?


See sdparm and hdparm tools. hdparm is probably the wrong tool because it's for internal drives connected to IDE/ATA/SATA busses. The reason sdparm works for USB drives is because of SCSI-over-USB emulation. See man page for more info.

The best way to do it is with a udev rule that will run some commands when the USB device gets plugged in. Otherwise the device resets it's config each time you plug it in.

Here's an actual example from my system:

-->cat /etc/udev/rules.d/86-Seagate-4TB-usb-disk-sleep.rules

ACTION=="add", SUBSYSTEM=="block", ENV{ID_SERIAL_SHORT}=="NA8E4BKU", RUN+="/usr/local/sbin/udev-set-usb-hdd-spindown.sh"



-->cat /usr/local/sbin/udev-set-usb-hdd-spindown.sh
#!/bin/bash

PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin"

# Seagate USB3 4TB disk drive.
DISK_DEV=/dev/disk/by-id/usb-Seagate_Expansion_Desk_NA8E4BKU-0:0
if [[ -e "$DISK_DEV" ]] ; then
        logger "Setting spindown on disk drive: $DISK_DEV"
        sdparm --flexible -6 --set SCT=4000 $DISK_DEV
        sdparm --flexible -6 --set STANDBY=1 $DISK_DEV
fi ; unset DISK_DEV


There's a convoluted reason why I call the script instead of just running the commands in the udev rule itself. If possible I'd tell you to just use a udev rule and skip the external script. Do what's right for you.

There might be some GUI tool out there that will do this for you but that's how I do it. See man pages and google for more hints. Good luck.



Reply to: