Tutorial.
If you want to spindown your external HDD, scsi-stop tool may help you. This tool is a part of scsi-idle package. If you don't want to build the tool from sources, just use the first link to get a prebuilt binary provided by Oleg.
Since you want to spindown your disk it is not very sensible to place the binary on it. So the appropriate place is the router's flash.
Steps:
1.
Code:
cd /usr/local/sbin
wget http://oleg.wl500g.info/bin/scsi-stop
chmod a+x scsi-stop
2. Now you can test your disk for compatibility. Please, ensure your login shell is /bin/sh and you run scsi-stop in it. cat /etc/passwd will help you to find out.
Code:
/usr/local/sbin/scsi-stop /dev/scsi/host0/bus0/target0/lun0/disc
If your disk continues to spin then scsi-stop most likely doesn't support your ide->usb (or sata->usb) box.
Please, post your results and your hardware here. Let other people know whether it is supported or not. And please add the output of
Code:
cat /proc/scsi/usb-storage-0/0
and search for corresponding VendorID&ProductID in the output of
Code:
cat /proc/bus/usb/devices
3. If you were successful you maybe would want to use my script for automatic spindown:
Code:
#!/bin/sh
if /usr/bin/[ $# -ne 1 ]; then
/bin/echo 1>&2 "Usage: $0 <device>"
exit 1
fi
PERIOD=30
BOUNDARY=1200
SCSISTOP=/usr/local/sbin/scsi-stop
LOGFILE=/tmp/scsi-stop.log
searchstr="disk_io:"
devaddr="(`/bin/ls -l $1 | /usr/bin/awk '{print($5 int($6/16))}'`)"
str=`/bin/grep "$searchstr" /proc/stat | devaddr="$devaddr" /usr/bin/awk -v 'RS= |\n' -F : '{ if($1==ENVIRON["devaddr"]) print($2) }'`
cooltime=0
stopped=0
while /bin/true; do
/bin/sleep $PERIOD
newstr=`/bin/grep "$searchstr" /proc/stat | devaddr="$devaddr" /usr/bin/awk -v 'RS= |\n' -F : '{ if($1==ENVIRON["devaddr"]) print($2) }'`
if /usr/bin/[ "$newstr" = "$str" ]; then
cooltime=$(($cooltime + $PERIOD))
if /usr/bin/[ $cooltime -ge $BOUNDARY -a $stopped -eq 0 ]; then
$SCSISTOP $1
time=`/bin/date '+%b %e %H:%M:%S'`
/bin/echo "$time: Cooled down..." >> $LOGFILE
stopped=1
fi
else
if /usr/bin/[ $cooltime -ne 0 ]; then
time=`/bin/date '+%b %e %H:%M:%S'`
/bin/echo "$time: Disk first used after $cooltime seconds" >> $LOGFILE
fi
cooltime=0
str=$newstr
stopped=0
fi
done
You can change "period" and "boundary" variables. They are in seconds. With the current settings script will wake up every 30 seconds to gather information and after 20 minutes of inactivity it will stop disk.
Do:
Code:
cd /usr/local/sbin
cat > scsi-stop.sh
<copy and paste the script>
<press Ctrl-C>
chmod a+x scsi-stop.sh
To run script in background do, for example:
Code:
./scsi-stop.sh /dev/scsi/host0/bus0/target0/lun0/disc &
Notice that the script writes some log messages to /tmp/scsi-stop.log .
4. Don't forget to do
Code:
flashfs save
flashfs commit
flashfs enable
to save all the things in the router's flash.
The most important: Hardware Compatibility List.
Working:
1.
HDD: Samsung SP2504C (sata)
Box: Vantec NexStar3 NST-360SU-BK
Bridge vendor: Sunplus Technology Inc.
cat /proc/scsi/usb-storage-0/0:
Host scsi0: usb-storage
Vendor: Sunplus Technology Inc.
Product: USB to Serial-ATA bridge
Serial Number: SAMSUNG SPS09QJ1NL805434
Protocol: Transparent SCSI
Transport: Bulk
GUID: 04fc0c15317ffffffffffff9
Attached: Yes
From /proc/bus/usb/devices: Vendor=04fc ProdID=0c15 Rev=c6.83
Not working:
1.
HDD: Seagate Barracuda 7200.9 (ide)
Bridge vendor: Cypress Semiconductor
Bridge chip: CY7C68300A-56PVC
2.
Bridge vendor: Cypress Semiconductor
cat /proc/scsi/usb-storage-0/0:
Host scsi0: usb-storage
Vendor: Cypress Semiconductor
Product: USB2.0 Storage Device
Serial Number: DEF10C9308EE
Protocol: Transparent SCSI
Transport: Bulk
GUID: 04b468300000def10c9308ee
Attached: Yes
3.
HDD: WD1600SD
Box: Vizo Luxon
Bridge vendor: JMicron
cat /proc/scsi/usb-storage-0/0:
Host scsi0: usb-storage
Vendor: JMicron
Product: JM20338 SATA, USB Combo
Serial Number: 8D88CA892915
Protocol: Transparent SCSI
Transport: Bulk
GUID: 152d233800008d88ca892915
4.
HDD: WD400VE
Box: Sarotech Cutie OTG FHD-254UM
cat /proc/scsi/usb-storage-0/0:
Host scsi3: usb-storage
Vendor: Unknown
Product: USB 2.0 Storage Device
Serial Number: 00000000000123456789
Protocol: Transparent SCSI
Transport: Bulk
GUID: 040256370000000123456789
I think this box has actually this chip:
Vendor: ALi Corp.
Product: M5637 IDE Controller
Update:
I tried to summarize all the gathered information in this post:
http://wl500g.info/showpost.php?p=52360&postcount=20
I'll keep it up to date.