Put an external USB 3.0 drive in standby mode

  • #  raspberry pi
  • #  linux
  • #  nas
  • My brand new external “Seagate One Touch” USB 3.0 drive didn’t want to spin down and go into standby mode after not being used for a while.

    Firstly, I tried hdparm for adjusting drive’s power settings, but the drive failed to accept the command.

    sudo hdparm -i /dev/sdb
    
    /dev/sdb:
    SG_IO: bad/missing sense data, sb[]:  70 00 05 00 00 00 00 0a 00 ...
     HDIO_GET_IDENTITY failed: Invalid argument
    

    A short research showed that the drive supported SCSI interface and sdparm utility should have been used instead.

    1. Install the utility by calling sudo apt-get install sdparm
    2. Find the path to the drive, e.g. by using lsblk -fs
    3. Read current power settings from the drive
    sudo sdparm --flexible -6 -l -a /dev/sdb
    
      STANDBY       0 [cha: y, def:  1, sav:  1]  Standby_z timer enable
      SCT           18000  [cha: y, def:3000, sav:3000]  Standby_z condition timer (100 ms)
    

    Many parameters will be printed out, but only STANDBY (0 - off, 1 - on) and SCT (MINUTES * 60 * 1000 / 50, e.g. 6000 for a 5 minutes timeout) are of our interest.

    50 ms used in the formula was the right value for my drive. For other drives the value could be 100ms, see this post for more details.

    1. Enable standby mode and set the desired timeout (5 minutes in my example):
    sudo sdparm --flexible -6 -l --save --set SCT=6000,STANDBY=1 /dev/sdb
    
        /dev/sdb: Seagate   One Touch HDD     0002
    
    1. Check the changes to power settings of the drive
    sudo sdparm --flexible -6 -l -a /dev/sdb
    
      STANDBY       1  [cha: y, def:  1, sav:  1]  Standby_z timer enable
      SCT           6000  [cha: y, def:3000, sav:3000]  Standby_z condition timer (100 ms)
    

    The values should be the values you’ve just set. Now, if you don’t access the drive for 5 minutes, it will spin down and go into standby mode.

    ☝️ The --save option at step (4) ensures that the settings are persisted in the drive and stay applied on each new power-up cycle of the drive. This was the case for me.

    If you are less lucky with your drive and the settings return to their factory defautls after the drive is reconnected, you will need to apply power settings each time the drive is connected. This can be automated by using udev utility.