特殊:Badtitle/NS100:ExternalDriveStandby:修订间差异
小无编辑摘要 |
小无编辑摘要 |
||
第73行: | 第73行: | ||
</nowiki></pre> | </nowiki></pre> | ||
The above would cause external drives to spin-down after 25-27 min of inactivity. Even though 25 min (1500 sec) is specified, the internal delay loop can add a couple minutes to the reaction time. | The above would cause external drives to spin-down after 25-27 min of inactivity. Even though 25 min (1500 sec) is specified, the internal delay loop can add a couple minutes to the reaction time. | ||
Use: | |||
<pre><nowiki> | |||
sg_start --pc=3 /dev/sda | |||
</nowiki></pre> | |||
..for "standby" mode, which still causes the disc to spin down but allows it to automatically spin back up when accessed. | |||
Enjoy! | Enjoy! | ||
---- | ---- |
2010年5月19日 (三) 22:18的最新版本
文章出处: |
{{#if: | {{{2}}} | https://help.ubuntu.com/community/ExternalDriveStandby }} |
点击翻译: |
English {{#ifexist: {{#if: UbuntuHelp:ExternalDriveStandby | UbuntuHelp:ExternalDriveStandby | {{#if: | :}}ExternalDriveStandby}}/af | • {{#if: UbuntuHelp:ExternalDriveStandby|Afrikaans| [[::ExternalDriveStandby/af|Afrikaans]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ExternalDriveStandby | UbuntuHelp:ExternalDriveStandby | {{#if: | :}}ExternalDriveStandby}}/ar | • {{#if: UbuntuHelp:ExternalDriveStandby|العربية| [[::ExternalDriveStandby/ar|العربية]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ExternalDriveStandby | UbuntuHelp:ExternalDriveStandby | {{#if: | :}}ExternalDriveStandby}}/az | • {{#if: UbuntuHelp:ExternalDriveStandby|azərbaycanca| [[::ExternalDriveStandby/az|azərbaycanca]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ExternalDriveStandby | UbuntuHelp:ExternalDriveStandby | {{#if: | :}}ExternalDriveStandby}}/bcc | • {{#if: UbuntuHelp:ExternalDriveStandby|جهلسری بلوچی| [[::ExternalDriveStandby/bcc|جهلسری بلوچی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ExternalDriveStandby | UbuntuHelp:ExternalDriveStandby | {{#if: | :}}ExternalDriveStandby}}/bg | • {{#if: UbuntuHelp:ExternalDriveStandby|български| [[::ExternalDriveStandby/bg|български]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ExternalDriveStandby | UbuntuHelp:ExternalDriveStandby | {{#if: | :}}ExternalDriveStandby}}/br | • {{#if: UbuntuHelp:ExternalDriveStandby|brezhoneg| [[::ExternalDriveStandby/br|brezhoneg]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ExternalDriveStandby | UbuntuHelp:ExternalDriveStandby | {{#if: | :}}ExternalDriveStandby}}/ca | • {{#if: UbuntuHelp:ExternalDriveStandby|català| [[::ExternalDriveStandby/ca|català]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ExternalDriveStandby | UbuntuHelp:ExternalDriveStandby | {{#if: | :}}ExternalDriveStandby}}/cs | • {{#if: UbuntuHelp:ExternalDriveStandby|čeština| [[::ExternalDriveStandby/cs|čeština]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ExternalDriveStandby | UbuntuHelp:ExternalDriveStandby | {{#if: | :}}ExternalDriveStandby}}/de | • {{#if: UbuntuHelp:ExternalDriveStandby|Deutsch| [[::ExternalDriveStandby/de|Deutsch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ExternalDriveStandby | UbuntuHelp:ExternalDriveStandby | {{#if: | :}}ExternalDriveStandby}}/el | • {{#if: UbuntuHelp:ExternalDriveStandby|Ελληνικά| [[::ExternalDriveStandby/el|Ελληνικά]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ExternalDriveStandby | UbuntuHelp:ExternalDriveStandby | {{#if: | :}}ExternalDriveStandby}}/es | • {{#if: UbuntuHelp:ExternalDriveStandby|español| [[::ExternalDriveStandby/es|español]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ExternalDriveStandby | UbuntuHelp:ExternalDriveStandby | {{#if: | :}}ExternalDriveStandby}}/fa | • {{#if: UbuntuHelp:ExternalDriveStandby|فارسی| [[::ExternalDriveStandby/fa|فارسی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ExternalDriveStandby | UbuntuHelp:ExternalDriveStandby | {{#if: | :}}ExternalDriveStandby}}/fi | • {{#if: UbuntuHelp:ExternalDriveStandby|suomi| [[::ExternalDriveStandby/fi|suomi]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ExternalDriveStandby | UbuntuHelp:ExternalDriveStandby | {{#if: | :}}ExternalDriveStandby}}/fr | • {{#if: UbuntuHelp:ExternalDriveStandby|français| [[::ExternalDriveStandby/fr|français]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ExternalDriveStandby | UbuntuHelp:ExternalDriveStandby | {{#if: | :}}ExternalDriveStandby}}/gu | • {{#if: UbuntuHelp:ExternalDriveStandby|ગુજરાતી| [[::ExternalDriveStandby/gu|ગુજરાતી]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ExternalDriveStandby | UbuntuHelp:ExternalDriveStandby | {{#if: | :}}ExternalDriveStandby}}/he | • {{#if: UbuntuHelp:ExternalDriveStandby|עברית| [[::ExternalDriveStandby/he|עברית]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ExternalDriveStandby | UbuntuHelp:ExternalDriveStandby | {{#if: | :}}ExternalDriveStandby}}/hu | • {{#if: UbuntuHelp:ExternalDriveStandby|magyar| [[::ExternalDriveStandby/hu|magyar]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ExternalDriveStandby | UbuntuHelp:ExternalDriveStandby | {{#if: | :}}ExternalDriveStandby}}/id | • {{#if: UbuntuHelp:ExternalDriveStandby|Bahasa Indonesia| [[::ExternalDriveStandby/id|Bahasa Indonesia]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ExternalDriveStandby | UbuntuHelp:ExternalDriveStandby | {{#if: | :}}ExternalDriveStandby}}/it | • {{#if: UbuntuHelp:ExternalDriveStandby|italiano| [[::ExternalDriveStandby/it|italiano]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ExternalDriveStandby | UbuntuHelp:ExternalDriveStandby | {{#if: | :}}ExternalDriveStandby}}/ja | • {{#if: UbuntuHelp:ExternalDriveStandby|日本語| [[::ExternalDriveStandby/ja|日本語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ExternalDriveStandby | UbuntuHelp:ExternalDriveStandby | {{#if: | :}}ExternalDriveStandby}}/ko | • {{#if: UbuntuHelp:ExternalDriveStandby|한국어| [[::ExternalDriveStandby/ko|한국어]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ExternalDriveStandby | UbuntuHelp:ExternalDriveStandby | {{#if: | :}}ExternalDriveStandby}}/ksh | • {{#if: UbuntuHelp:ExternalDriveStandby|Ripoarisch| [[::ExternalDriveStandby/ksh|Ripoarisch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ExternalDriveStandby | UbuntuHelp:ExternalDriveStandby | {{#if: | :}}ExternalDriveStandby}}/mr | • {{#if: UbuntuHelp:ExternalDriveStandby|मराठी| [[::ExternalDriveStandby/mr|मराठी]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ExternalDriveStandby | UbuntuHelp:ExternalDriveStandby | {{#if: | :}}ExternalDriveStandby}}/ms | • {{#if: UbuntuHelp:ExternalDriveStandby|Bahasa Melayu| [[::ExternalDriveStandby/ms|Bahasa Melayu]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ExternalDriveStandby | UbuntuHelp:ExternalDriveStandby | {{#if: | :}}ExternalDriveStandby}}/nl | • {{#if: UbuntuHelp:ExternalDriveStandby|Nederlands| [[::ExternalDriveStandby/nl|Nederlands]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ExternalDriveStandby | UbuntuHelp:ExternalDriveStandby | {{#if: | :}}ExternalDriveStandby}}/no | • {{#if: UbuntuHelp:ExternalDriveStandby|norsk| [[::ExternalDriveStandby/no|norsk]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ExternalDriveStandby | UbuntuHelp:ExternalDriveStandby | {{#if: | :}}ExternalDriveStandby}}/oc | • {{#if: UbuntuHelp:ExternalDriveStandby|occitan| [[::ExternalDriveStandby/oc|occitan]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ExternalDriveStandby | UbuntuHelp:ExternalDriveStandby | {{#if: | :}}ExternalDriveStandby}}/pl | • {{#if: UbuntuHelp:ExternalDriveStandby|polski| [[::ExternalDriveStandby/pl|polski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ExternalDriveStandby | UbuntuHelp:ExternalDriveStandby | {{#if: | :}}ExternalDriveStandby}}/pt | • {{#if: UbuntuHelp:ExternalDriveStandby|português| [[::ExternalDriveStandby/pt|português]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ExternalDriveStandby | UbuntuHelp:ExternalDriveStandby | {{#if: | :}}ExternalDriveStandby}}/ro | • {{#if: UbuntuHelp:ExternalDriveStandby|română| [[::ExternalDriveStandby/ro|română]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ExternalDriveStandby | UbuntuHelp:ExternalDriveStandby | {{#if: | :}}ExternalDriveStandby}}/ru | • {{#if: UbuntuHelp:ExternalDriveStandby|русский| [[::ExternalDriveStandby/ru|русский]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ExternalDriveStandby | UbuntuHelp:ExternalDriveStandby | {{#if: | :}}ExternalDriveStandby}}/si | • {{#if: UbuntuHelp:ExternalDriveStandby|සිංහල| [[::ExternalDriveStandby/si|සිංහල]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ExternalDriveStandby | UbuntuHelp:ExternalDriveStandby | {{#if: | :}}ExternalDriveStandby}}/sq | • {{#if: UbuntuHelp:ExternalDriveStandby|shqip| [[::ExternalDriveStandby/sq|shqip]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ExternalDriveStandby | UbuntuHelp:ExternalDriveStandby | {{#if: | :}}ExternalDriveStandby}}/sr | • {{#if: UbuntuHelp:ExternalDriveStandby|српски / srpski| [[::ExternalDriveStandby/sr|српски / srpski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ExternalDriveStandby | UbuntuHelp:ExternalDriveStandby | {{#if: | :}}ExternalDriveStandby}}/sv | • {{#if: UbuntuHelp:ExternalDriveStandby|svenska| [[::ExternalDriveStandby/sv|svenska]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ExternalDriveStandby | UbuntuHelp:ExternalDriveStandby | {{#if: | :}}ExternalDriveStandby}}/th | • {{#if: UbuntuHelp:ExternalDriveStandby|ไทย| [[::ExternalDriveStandby/th|ไทย]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ExternalDriveStandby | UbuntuHelp:ExternalDriveStandby | {{#if: | :}}ExternalDriveStandby}}/tr | • {{#if: UbuntuHelp:ExternalDriveStandby|Türkçe| [[::ExternalDriveStandby/tr|Türkçe]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ExternalDriveStandby | UbuntuHelp:ExternalDriveStandby | {{#if: | :}}ExternalDriveStandby}}/vi | • {{#if: UbuntuHelp:ExternalDriveStandby|Tiếng Việt| [[::ExternalDriveStandby/vi|Tiếng Việt]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ExternalDriveStandby | UbuntuHelp:ExternalDriveStandby | {{#if: | :}}ExternalDriveStandby}}/yue | • {{#if: UbuntuHelp:ExternalDriveStandby|粵語| [[::ExternalDriveStandby/yue|粵語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ExternalDriveStandby | UbuntuHelp:ExternalDriveStandby | {{#if: | :}}ExternalDriveStandby}}/zh | • {{#if: UbuntuHelp:ExternalDriveStandby|中文| [[::ExternalDriveStandby/zh|中文]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ExternalDriveStandby | UbuntuHelp:ExternalDriveStandby | {{#if: | :}}ExternalDriveStandby}}/zh-hans | • {{#if: UbuntuHelp:ExternalDriveStandby|中文(简体)| [[::ExternalDriveStandby/zh-hans|中文(简体)]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ExternalDriveStandby | UbuntuHelp:ExternalDriveStandby | {{#if: | :}}ExternalDriveStandby}}/zh-hant | • {{#if: UbuntuHelp:ExternalDriveStandby|中文(繁體)| [[::ExternalDriveStandby/zh-hant|中文(繁體)]]}}|}} |
{{#ifeq:UbuntuHelp:ExternalDriveStandby|:ExternalDriveStandby|请不要直接编辑翻译本页,本页将定期与来源同步。}} |
{{#ifexist: :ExternalDriveStandby/zh | | {{#ifexist: ExternalDriveStandby/zh | | {{#ifeq: {{#titleparts:ExternalDriveStandby|1|-1|}} | zh | | }} }} }} {{#ifeq: {{#titleparts:ExternalDriveStandby|1|-1|}} | zh | | }}
Automatic Spin-Down For Idle External Hard Drives
It is often desirable to have external hard drives - such as those attached by USB and Firewire - spin down into a power-saving or 'standby' mode after a certain period of inactivity. Since these external drives cannot have their standby parameters set with 'hdparm' (which only handles IDE devices and not the pseudo-SCSI ones), some way other than the built-in method is required to make these drives spin down.
Requirements
K/Ubuntu 7.04 or later; The 'sg3-utils' package.
The Script
Save the following code as 'scsi-idle' and set the execute flag for it: Note: You must delete the space before the #!/bin/bash on line 1.
#!/bin/bash declare -a DID declare -a DSTATUS declare -a DTIME declare -a DOFF interval=$1 sleepval=120 buspath=/sys/bus/scsi/devices while [ true ]; do thetime=`date +%s` for scsidev in $( ls --format=across $buspath ); do if devenum="$( ls ${buspath}/${scsidev} | grep 'block:' )"; then devdir=$buspath/$scsidev/$devenum read devsize < ${devdir}/size read devremove < ${devdir}/removable if [ $devremove -eq 0 ] && [ $devsize -gt 0 ]; then # device is the right type read newstat < ${devdir}/stat hhit=0; listlen=${#DID[@]} #; echo $listlen $scsidev for ((i=0;i<$listlen;i++)); do if [ ${DID[$i]} = $scsidev ]; then if [ "${DSTATUS[$i]}" = "$newstat" ]; then if [ $[ ${thetime} - ${DTIME[$i]} ] -ge $interval ] \ && [ ${DOFF[$i]} -eq 0 ]; then sg_start --pc=5 /dev/${devenum:6} # put into sleep mode # sg_start --stop /dev/${devenum:6} # alternate method echo stop /dev/${devenum:6} DTIME[$i]=$thetime DOFF[$i]=1 fi else DSTATUS[$i]=$newstat DTIME[$i]=$thetime DOFF[$i]=0 fi hhit=1; break fi done if [ $hhit -eq 0 ]; then # add new drive to watch list DID[$listlen]=$scsidev DSTATUS[$listlen]=$newstat DTIME[$listlen]=`date +%s` DOFF[$listlen]=0 fi fi fi done sleep $sleepval done
Run it in the background like this:
$ sudo ./scsi-idle 1500 &
The above would cause external drives to spin-down after 25-27 min of inactivity. Even though 25 min (1500 sec) is specified, the internal delay loop can add a couple minutes to the reaction time. Use:
sg_start --pc=3 /dev/sda
..for "standby" mode, which still causes the disc to spin down but allows it to automatically spin back up when accessed. Enjoy!