Seagate FreeAgent drive auto spindown under Linux solutions

Last modified on 2009-12-01

I bought a Seagate FreeAgent Pro hard drive, but find it doesn't work well under Linux. After some investigation, I find the following solutions.

Solution 1: Turn off the auto spindown/spinup ability of external drive.

# sdparm -a /dev/sdb
    /dev/sdb: Seagate   FreeAgent Pro  400A
Power condition mode page:
  IDLE        0  [cha: n, def:  0, sav:  0]
  STANDBY     1  [cha: y, def:  1, sav:  1]
  ICT         0  [cha: n, def:  0, sav:  0]
  SCT       9000  [cha: y, def:9000, sav:9000]

# sdparm --clear STANDBY -6 /dev/sdb

# sdparm -a /dev/sdb
    /dev/sdb: Seagate   FreeAgent Pro  400A
Power condition mode page:
  IDLE        0  [cha: n, def:  0, sav:  0]
  STANDBY     0  [cha: n, def:  1, sav:  0]
  ICT         0  [cha: n, def:  0, sav:  0]
  SCT         0  [cha: n, def:9000, sav:  0]

To restore the default value:

# sdparm -D -p 0x1a -6 /dev/sdb

To change the default standby condition timer to 1 hour:

$ sudo sdparm -al /dev/sdb
    /dev/sdb: Seagate   Portable          0130
    Direct access device specific parameters: WP=0  DPOFUA=0
Power condition [po] mode page:
  PM_BG       0  [cha: n, def:  0, sav:  0]  Power management, background functions, precedence
  STANDBY_Y   0  [cha: n, def:  0, sav:  0]  Standby_y timer enabled
  IDLE_C      0  [cha: n, def:  0, sav:  0]  Idle_c timer enabled
  IDLE_B      0  [cha: n, def:  0, sav:  0]  Idle_b timer active
  IDLE        0  [cha: n, def:  0, sav:  0]  Idle timer enabled
  STANDBY     1  [cha: y, def:  1, sav:  1]  Standby timer active
  ICT         0  [cha: n, def:  0, sav:  0]  Idle condition timer (100 ms)
  SCT       36000  [cha: y, def:3000, sav:3000]  Standby condition timer (100 ms)
SAT ATA Power condition [apo] mode page:
  APMP        0  [cha: n, def:  0, sav:  0]  Advanced Power Management (APM) enabled/change
  APM         0  [cha: n, def:  0, sav:  0]  Advanced Power Management (APM) value
$ sudo sdparm -s SCT=36000 --save /dev/sdb
    /dev/sdb: Seagate   Portable          0130
$ sudo sdparm -al /dev/sdb
    /dev/sdb: Seagate   Portable          0130
    Direct access device specific parameters: WP=0  DPOFUA=0
Power condition [po] mode page:
  PM_BG       0  [cha: n, def:  0, sav:  0]  Power management, background functions, precedence
  STANDBY_Y   0  [cha: n, def:  0, sav:  0]  Standby_y timer enabled
  IDLE_C      0  [cha: n, def:  0, sav:  0]  Idle_c timer enabled
  IDLE_B      0  [cha: n, def:  0, sav:  0]  Idle_b timer active
  IDLE        0  [cha: n, def:  0, sav:  0]  Idle timer enabled
  STANDBY     1  [cha: y, def:  1, sav:  1]  Standby timer active
  ICT         0  [cha: n, def:  0, sav:  0]  Idle condition timer (100 ms)
  SCT       36000  [cha: y, def:3000, sav:36000]  Standby condition timer (100 ms)
SAT ATA Power condition [apo] mode page:
  APMP        0  [cha: n, def:  0, sav:  0]  Advanced Power Management (APM) enabled/change
  APM         0  [cha: n, def:  0, sav:  0]  Advanced Power Management (APM) value

Solution 2: Make the drive auto restart.

Using Udev

  1. Get drive info by udevinfo:

    # udevinfo -a -p /sys/block/sdb | less
    
  2. As root, create /etc/udev/rules.d/85-usb-hd-fix.rules with contents:

    SUBSYSTEMS=="scsi",DRIVERS=="sd",ATTRS{vendor}=="Seagate",ATTRS{model}=="FreeAgentPro",RUN+="/usr/bin/usbhdfix %k"
    
  3. As root, create /usr/bin/usbhdfix, mode 755 with contents:

    #!/bin/bash # Script is in fact called 5 times on SuSE, with different values # Use grep to find if the values fit an appropriate form and only # then should we attempt to perform any actions # Strings fit form of [0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2} # Nonetheless, for usb devices the first portion should be enough id=$(echo $1 | grep '^[0-9]\{1,2\}:[0-9]\{1,2\}') if [ -n "$id" ]; then echo 1 > /sys/class/scsi_disk/$id/allow_restart fi

Using system service

  1. As root, create /etc/init.d/usbhdfix, mode 755 with contents:

    #!/bin/sh
    # usbhdfix	Fix usb hard drive auto spindown issue
    # chkconfig: 2345 60 20
    # description: Fix usb hard drive auto spindown issue by enable auto_restart
    #              kernel flag.
    case "$1" in
      start)
            find /sys -name allow_restart | while read i
            do
                echo $i
                echo 1 > $i
            done
            ;;
      stop)
            echo "Unmounting USB fileystem."
    	    ;;
      restart|reload|force-reload)
            ;;
      *)
            echo "Usage: /etc/init.d/usbhdfix start|stop|restart|reload|force-reload"
            exit 1 
            ;;
    esac
    
    exit 0
    
  2. Make it auto start at system boot:

    # chkconfig --level 2345 usbhdfix on
    

Solution 3: Using FreeAgent software provided by Seagate

You should connect the hard drive to a Windows host and install the FreeAgent tool. Then change the auto spindown time to "nerver". You can also turn down the light of the drive, which cannot be done under linux.

Reference

  1. Seagate Free Agent Drive.
  2. The sdparm utility.
  3. DealWithAutoSpinDownOnSeagateFreeAgent.
  4. USB HD gives I/O errors while spinning up.
  5. FreeAgent Drives spin down issue.
  6. Seagate Free Agent Pro Forgets eSATA Cable For a Reason.
  7. USB Hard drive randomly unmounting and remounting.
  8. Seagate Freeagent + Allow_restart + Udev + 10.3, For those with a Seagate FreeAgent trying to get it to allow_restart.
  9. [PATCH] SCSI error handling on some USB disks needs allow_restart.