How can I spin down external hard drive?
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.
The udisk option did not work in my case but the following did:
sudo umount /dev/sdb1
sudo hdparm -y /dev/sdb
I make use of these commands when remotely shutting down a headless Linux server with an external USB drive. Security is not a concern in my case, so the server password is in the script.
For a Ubuntu server and Windows client the following batch file, assuming PuTTY is installed:
C:\"Program Files (x86)\PuTTY\plink.exe" -ssh -t -l SERVERUSERNAME -pw PASSWORD -noagent 192.168.2.22 "echo PASSWORD | sudo umount /dev/sdb1 ; sudo -S hdparm -y /dev/sdb; sudo -S halt -i now"
For a Debian server, replace sudo halt -i now
with shutdown -h -P
; in both cases the network card stays awake, so it can be awaken later.
If it is 2.5" drive you should be able to hear your drive make click sound about 15 seconds after unmout. That is when drive parked reading/writing heads aside and you can safely remove it. If it is 3.5" drive then there is no way to make removing safer by spinning the drive down.