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

Re: Controlling power settings for external USB disk drives using sdparm




Update to this:

In the message below, I said that setting "SCT=18000" would be a 15 minute spindown, but this does not appear to be correct.

I suspect this parameter is like the hdparm -S argument, which is non-linear.

I have confirmed that SCT=1200 is 1-minute, and SCT=3000 is 5-minutes.

I tested with SCT=9000 but about two hours later the drive is still spinning.

If you want a spindown time longer than 5-minutes, you'll have to figure it out yourself, because I have no idea.

Additionally, I wrote the following compound "--set" command below:
"sdparm --flexible -6 -l --set SCT=18000 --set STANDBY=1 /dev/sdb"

This doesn't appear to work right, even though the man page says it's possible and there are no errors. If you issue the set commands independently though, it works:

sdparm --flexible -6 -l --set SCT=18000 /dev/sdb
sdparm --flexible -6 -l --set STANDBY=1 /dev/sdb



Notes updated with corrections:

# Show your disks and devices
        udisksctl status
        udisksctl info -b /dev/sdb

# Interogate the device to collect info:
        sudo sdparm --flexible -6 -l -i /dev/sdb
        sudo sdparm --flexible -6 -l -i -a /dev/sdb

# Show all of the parameters/settings:
        sudo sdparm --flexible -6 -l -a /dev/sdb

# Immediately start and stop the disk:
        sudo sdparm --readonly --command=stop /dev/sdb
        sudo sdparm --command=start /dev/sdb
# Per the hdparm man page, It may be necessary to mark the disk as "offline" with:
        #       sudo bash -c 'echo offline > /sys/block/sdb/device/state'
        # Normalize with:
        #       sudo bash -c 'echo running > /sys/block/sdb/device/state'

# Get the auto-spindown parameter current settings:
        sudo sdparm --flexible -6 -l --get SCT /dev/sdb
        sudo sdparm --flexible -6 -l --get STANDBY /dev/sdb
        # SCT = spindown timer in 100 miliseconds.
# NOTE: The sdparm man page says SCT is measured in 100ms. but for my Seagate drive, it varies. # STANDBY = the spindown timer on/off switch. 0=off (never spin down), 1=on (spin down to timer)
        # These were my default values on my ST4000DM000:
        #  STANDBY     0  [cha: y, def:  1, sav:  1]
        #  SCT       4294967286  [cha: y, def:9000, sav:9000]
        # This means the device NEVER spins down by default.

# Set the auto-spindown parameters to spin down after 5 minutes of inactivity:
        sudo sdparm --flexible -6 -l --set SCT=3000 /dev/sdb
        sudo sdparm --flexible -6 -l --set STANDBY=1 /dev/sdb
        # NOTE: this these settings are lost on reboot.

# Set and save the auto-spindown parameters to spin down after 5 minutes of inactivity:
        sudo sdparm --flexible -6 -l --save --set SCT=3000 /dev/sdb
        sudo sdparm --flexible -6 -l --save --set STANDBY=1 /dev/sdb
# NOTE: Values will be saved to the device and *should* be retained between reboots and host moves. # NOTE: My Seagate ST4000DM000 failed to save settings. Not all drives will support this.



On 8/4/15 3:09, Jesse Molina wrote:

Hi everyone

I wanted to post, for posterity, what I recently learned while playing with my new external USB3 disk drive.

I needed to control the power settings for this drive. I noticed that it was never ever spinning down, so I wanted to be able to either power in up/down on command, or have it automatically spin down after a period of inactivity. In the end, I was able to do both.

My device is a Seagate ST4000DM000. This should probably work for similar Seagate enclosures, like the STEB2000100, STEB3000100, and STEB5000100.

I wasn't able to get hdparm to work with my device at all, but that should probably be your first step. See if "hdparm -i" works, then do a -I, then try setting the spin-down with -S.

I had to use the sdparm tool instead, and the notes here reflect what worked for me.

WARNING: Use the /dev/disk/by-id path for USB devices, not letter-device path like the sdb example I used below.

# Show your disks and devices
        udisksctl status
        udisksctl info -b /dev/sdb

# Interogate the device to collect info:
        sudo sdparm --flexible -6 -l -i /dev/sdb
        sudo sdparm --flexible -6 -l -i -a /dev/sdb

# Show all of the parameters/settings:
        sudo sdparm --flexible -6 -l -a /dev/sdb

# Immediately start and stop the disk:
        sudo sdparm --readonly --command=stop /dev/sdb
        sudo sdparm --command=start /dev/sdb
# Per the hdparm man page, It may be necessary to mark the disk as "offline" with:
        #       sudo bash -c 'echo offline > /sys/block/sdb/device/state'
        # Normalize with:
        #       sudo bash -c 'echo running > /sys/block/sdb/device/state'

# Get the auto-spindown parameter current settings:
        sudo sdparm --flexible -6 -l --get SCT /dev/sdb
        sudo sdparm --flexible -6 -l --get STANDBY /dev/sdb
        # SCT = spindown timer in 100 miliseconds.
# NOTE: The sdparm man page says SCT is measured in 100ms. but for my Seagate drive, it's actually 1=50ms. # STANDBY = the spindown timer on/off switch. 0=off (never spin down), 1=on (spin down to timer)
        # These were my default values on my ST4000DM000:
        #  STANDBY     0  [cha: y, def:  1, sav:  1]
        #  SCT       4294967286  [cha: y, def:9000, sav:9000]
        # This means the device NEVER spins down by default.

# Set the auto-spindown parameters to spin down after 15 minutes of inactivity (assuming SCT=50ms instead of 100ms):
        sudo sdparm --flexible -6 -l --set SCT=18000 /dev/sdb
        sudo sdparm --flexible -6 -l --set STANDBY=1 /dev/sdb
        # NOTE: this these settings are lost on reboot.

# Set the auto-spindown parameters to spin down after 15 minutes of inactivity (assuming SCT=50ms instead of 100ms):
        sudo sdparm --flexible -6 -l --save --set SCT=18000 /dev/sdb
        sudo sdparm --flexible -6 -l --save --set STANDBY=1 /dev/sdb
# NOTE: Values will be saved to the device and *should* be retained between reboots and host moves. # NOTE: My Seagate ST4000DM000 failed to save settings. Seagate sucks. Whatever.



Finally, I put this in my /etc/rc.local to set on boot:

sdparm --flexible -6 -l --set SCT=18000 --set STANDBY=1 /dev/sdb


I hope this helps someone. The HOWTOs and examples I found while searching the internet didn't really help me that much. I had to do a lot of experimenting before I discovered that this device would not really talk to me without "--flexible -6" being set, and that "--readonly" was required with the stop command (or it just spun right back up).

If you have any feedback or corrections, let me know!





Reply to: