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
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
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.
Seagate FreeAgent drive auto spindown under Linux solutions
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:
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) valueSolution 2: Make the drive auto restart.
Using Udev
Get drive info by udevinfo:
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"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 fiUsing system service
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 0Make it auto start at system boot:
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
Categories
Feeds
Tags
Copyright © 2012 Zhigang Wang. Some right reserved.
The views expressed on this web site are my own and do not necessarily reflect the views of Oracle.