數位天堂

Nokia:科技始終來自於人性; 拜耳:如果文明不能使我們更相愛,那科技便失去意義!
歡迎您的加入,讓我們一起討論科技與環保的整合應用...

您尚未登入。

#11 2010-11-28 19:13:23

tsengleoo
新生
註冊日期: 2010-06-05
文章數: 16
目前積分 :   

Re: 外接USB硬碟,有無方法可以關閉電源進入省電模式

ardayang 提到:

tsengleoo 提到:

似乎顯示SATA(sda)硬碟就沒辦法使用這邊的東西了...

經測試,用在sata硬碟是可以的.

安裝完後執行第二步驟
就顯示
/dev/sda is not a SCSI block device



離線

 

#12 2012-01-30 22:42:37

ardayang
精靈
註冊日期: 2008-05-25
文章數: 104
目前積分 :   

Re: 外接USB硬碟,有無方法可以關閉電源進入省電模式

下面的腳本只適用在核心2.4版,有沒有大大可以幫忙改一下,讓他可以用在核心2.6版,謝謝!

#!/bin/sh if /usr/bin/[ $# -ne 1 ]; then /bin/echo 1>&2 "Usage: $0 " 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


目前是使用 http://tomatousb.org/forum/t-266375/ 的腳本

#!/bin/sh # author: karog # date: 17 Sep 2010 # ***USE AT YOUR OWN RISK*** # script name SCRIPTNAME="${0##*/}" # log /var/log/messages and add -s for stderr log () { logger -p user.info -t "$SCRIPTNAME" "$1" } # usage if [ $# -eq 0 ]; then log "Usage: $SCRIPTNAME device [idletime [checktime]] &" log " device /dev/sd[a-z]" log " idletime optional idle time in seconds before disk spindown (default 900)" log " checktime optional time in seconds to sleep between idle checks (default 30)" exit 0 fi DEVICE="$1" # validate form as /dev/sd[a-z] echo "$DEVICE" | grep -q "^/dev/sd[a-z]$" if [ $? -ne 0 ]; then log "Invalid device not of form /dev/sd[a-z]: $DEVICE; exiting" exit 1 fi # validate in the file system ls "$DEVICE" > /dev/null 2>&1 if [ $? -ne 0 ]; then log "Invalid device not in file system: $DEVICE; exiting" exit 1 fi # idle time IDLETIME=900 IDLETIME_MIN=300 if [ $# -gt 1 ]; then echo "$2" | grep -qE "^[[:digit:]]+$" if [ $? -eq 0 ]; then IDLETIME=$2 if [ "$IDLETIME" -lt "$IDLETIME_MIN" ]; then log "IDLETIME set too small which is bad for disks: $IDLETIME; setting to minimum $IDLETIME_MIN" IDLETIME="$IDLETIME_MIN" fi else log "Invalid idletime: $2; using default $IDLETIME" fi fi # check time CHECKTIME=30 CHECKTIME_MIN=5 if [ $# -gt 2 ]; then echo "$3" | grep -qE "^[[:digit:]]+$" if [ $? -eq 0 ]; then CHECKTIME=$3 if [ "$CHECKTIME" -lt "$CHECKTIME_MIN" ]; then log "CHECKTIME set too small: $CHECKTIME; setting to minimum $CHECKTIME_MIN" CHECKTIME="$CHECKTIME_MIN" fi else log "Invalid checktime: $3; using default $CHECKTIME" fi fi SPINNING=1 STOPPED=0 DEVNAME=${DEVICE##/dev/} DEVSTATS=`cat /proc/diskstats | grep " $DEVNAME "` DEVIDLE=0 DEVSTATE="$SPINNING" log "running" # forever while true; do sleep "$CHECKTIME" NEWSTATS=`cat /proc/diskstats | grep " $DEVNAME "` IOINPROGRESS=`echo $NEWSTATS | cut -d ' ' -f 12` # if no I/O in progress and stats have not changed if [ "$IOINPROGRESS" -eq 0 -a "$NEWSTATS" = "$DEVSTATS" ]; then # no disk activity let "DEVIDLE+=CHECKTIME" # test idle time exceeded and disk spinning if [ "$IDLETIME" -le "$DEVIDLE" -a "$DEVSTATE" -eq "$SPINNING" ]; then scsi-stop "$DEVICE" DEVSTATE="$STOPPED" log "$DEVICE spinning down" fi else # disk activity # if disk was stopped if [ "$DEVSTATE" -eq "$STOPPED" ]; then DEVSTATE="$SPINNING" let "SECS=DEVIDLE-IDLETIME" let "DAYS=SECS/86400,SECS-=DAYS*86400" let "HOURS=SECS/3600,SECS-=HOURS*3600" let "MINS=SECS/60,SECS-=MINS*60" if [ "$DAYS" -eq 0 ]; then DAYS=""; else DAYS="$DAYS days "; fi if [ "$HOURS" -eq 0 ]; then HOURS=""; else HOURS="$HOURS hrs "; fi if [ "$MINS" -eq 0 ]; then MINS=""; else MINS="$MINS mins "; fi if [ "$SECS" -eq 0 ]; then SECS=""; else SECS="$SECS secs "; fi log "$DEVICE spinning up after $DAYS$HOURS$MINS$SECS" fi DEVIDLE=0 DEVSTATS="$NEWSTATS" fi done



最後修改: ardayang (2012-01-30 23:40:39)


離線

 

#13 2012-02-12 21:17:48

Beast
新生
註冊日期: 2009-08-03
文章數: 8
目前積分 :   

Re: 外接USB硬碟,有無方法可以關閉電源進入省電模式

真是強,小弟的RT-N16目前是接16G USB,年歲已高,預定換成32G USB,目前是使用OLEG LLY的1.9.2.7-3789版本。

想到要從ssh, user, vsftpd, lighttpd、從頭再跑一次設定就頭痛,請教站上前輩,是否全部設定都要再來一次?或是有建議的方法呢?


離線

 

#14 2012-02-13 21:54:46

hippo
天使
註冊日期: 2008-10-07
文章數: 1562
目前積分 :   20 

Re: 外接USB硬碟,有無方法可以關閉電源進入省電模式

假設硬碟掛在/opt, 使用tar指令, 將整個/opt封裝壓縮, 再解壓縮到新硬碟.


離線

 

友情連結

論壇頁尾

Powered by PunBB
© Copyright 2018 Rickard Andersson
RSS Feed