You can safely unmount and spin-down an external hard disk from the terminal most easily by using the command-line functionality of udisks
, which does not require the use of sudo if your system is set up correctly. (To list your device names, enter mount
in the terminal first.)
When you have found your external drive, use the following commands. You must first unmount the partition (use sdb1
or whatever mount
showed as the location):
udisks --unmount /dev/sdb1
Then to safely remove (i.e. spindown- you will hear it click and spin-down), use only sdb
, for example:
udisks --detach /dev/sdb
NOTE: It is of crucial importance here that you use sdb
or sdc
without a partition number when using the detach
option; i.e. sdb1
or sdc1
will not work. The partition must be unmounted first and then the disk itself spun down as the examples show.
The udisks
commands work successfully for all my pata and sata external hard disks.
hd-idle utility should be helpful
Please look at the source given below, read carefully and see if it helps:
Download source code with CVS
using these commands:
cvs -d:pserver:anonymous@hd-idle.cvs.sourceforge.net:/cvsroot/hd-idle login
- Hit return when asked for password
cvs -z3 -d:pserver:anonymous@hd-idle.cvs.sourceforge.net:/cvsroot/hd-idle co -P hd-idle
Debians systems:
- Run:
dpkg-buildpackage -rfakeroot
- And to install the package run: 'dpkg -i ../hd-idle_*.deb'
Usage:
hd-idle
# This will start hd-idle with the default options,
# causing all SCSI (read: USB, Firewire, SCSI, ...) hard disks
# to spin down after 10 minutes of inactivity
Note: Please note that hd-idle uses /proc/diskstats
to read disk statistics. If this file is not present, hd-idle won't work.
Information:
Running hd-idle
In order to run hd-idle, type "hd-idle". This will start hd-idle with the default options, causing all SCSI (read: USB, Firewire, SCSI, ...) hard disks to spin down after 10 minutes of inactivity.
On a Debian system, after editing /etc/default/hd-idle and enabling it, use "/etc/init.d/hd-idle start" to run hd-idle.
Please note that hd-idle uses /proc/diskstats to read disk statistics. If this file is not present, hd-idle won't work.
Command line options
-a <name> Set (partial) device name of disks for subsequent idle-time parameters (-i). This parameter is optional in the sense that there's a default entry for all [SCSI] disks which are not named otherwise by using this parameter.
-i <idle_time> Idle time in seconds for the currently named disk(s) (-a <name>) or for all disks.
-l <logfile> Name of logfile (written only after a disk has spun up). Please note that this option might cause the disk which holds the logfile to spin up just because another disk had some activity. This option should not be used on systems with more than one disk except for tuning purposes. On single-disk systems, this option should not cause any additional spinups.
-t <disk> Spin-down the specified disk immediately and exit. Use only the disk name (e.g. sda) without /dev/ prefix
-d Debug mode. This will prevent hd-idle from becoming a daemon and print debugging info to stdout/stderr
-h Print brief usage information
Regarding the parameter "-a":
Users of hd-idle have asked for means to set idle-time parameters for individual disks. This makes a lot of sense, not only because some [SCSI] disks may not react well to being stopped. Originally, hd-idle had one idle time for all disks. The parameter "-a" can now be used to set a filter on the disk's device name (omit /dev/) for subsequent idle-time settings.
A "-i" option before the first "-a" option will set the default idle time; hence, compatibility with previous releases of hd-idle is maintained.
In order to disable spin-down of disks per default, and then re-enable spin-down on selected disks, set the default idle time to 0.
Example:
hd-idle -i 0 -a sda -i 300 -a sdb -i 1200
This example sets the default idle time to 0 (meaning hd-idle will never try to spin down a disk), then sets explicit idle times for disks which have the string "sda" or "sdb" in their device name.
Stopping hd-idle
Use killall hd-idle
to stop hd-idle. On a Debian system, use /etc/init.d/hd-idle stop
.
Source:
http://hd-idle.sourceforge.net/
Best Answer
hdparm -B 127
should configure your drive for maximum power savings however if there is a flush to disk then it has no choice but to wake up. To counter this you can installpowertop
to profile programs that write to disk repeatedly. If it's workable, you might be able to reconfigure those programs to write to a tmpfs mount of your creation, or by using an existing tmpfs like /run is up to your discretion. You could also adjust the swapiness and vm caching attributes to tell Linux to hold onto more ram, thus flushing to disk less. See the VM docs in the linux kernel,http://lxr.linux.no/linux+v3.1.2/Documentation/sysctl/vm.txt
andDocumentation/vm/
.