I want to spin down external hard drive from the terminal before unmounting.

It is an sata drive connected through usb.

Running hdparm gives this

 ry@G62x:/media$ hdparm -S10 937b2299-48ff-4a9c-8228-67ed4453e8fb/

 setting standby to 10 (50 seconds)
 HDIO_DRIVE_CMD(setidle) failed: Inappropriate ioctl for device

7 Answers 7


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.

  • 1
    How can I install udisks? It is not on my system. I found the package udisks2, but that did not make udisks or udisks2 available. May 14, 2016 at 8:06
  • @MartinThoma As of 12.04 it is in the Universe repository. As of 14.04 it is installed by default.
    – wjandrea
    Jun 17, 2016 at 23:29
  • 1
    @wjandrea I am using Ubuntu 16.04. No, it is not installed. At least I can't start it with udisks. Jun 18, 2016 at 7:16
  • 2
    -1 for using udisks. It's by no means any standard and thus not too helpful. Aug 1, 2016 at 19:10
  • 1
    -1 for suggesting udisks: The udisksd2 daemon is the number one offender for not letting your harddisks spin down in the first place based on their idle timeout (hdparm -S)! Unless the timeout is very short. It also causes unnecessary spin-ups – as a silly example, udisksctl --help will spin up all your disks (including unmounted ones). But the worst is that this udisk stuff is hard to ban from your system, because it is depended on by various of GUI programs – my best workaround is to killall -SIGSTOP udsiksd2 in a cron job and unfreeze those GUI applications with SIGCONT as needed. Feb 8, 2017 at 23:53

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 "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.

  • 1
    It is a 3.5", I can umount it, then unplug it and still hear it spinning an hour or so later. Aug 8, 2011 at 18:35

This answer is based on a lot of assumptions, as I do not remember the source of it. But here it is:

  1. SATA is actually hot-pluggable, but most of controllers do not support it, while SATA drives should.
  2. Based on point above: If a drive is unmounted, it is safe to unplug it. Base reason for that is point #3.
  3. Modern drives have enough power to remove drive heads from the platters in case of emergency power off that is detected.

At least this is what I do. And also, from time to time I do a long S.M.A.R.T. test on the disk, to see if the health of the drive is OK.

  • my understanding is that emergency head parks are more stressful on the drive and to be avoided, as they have a much lower rating than standard shut down procedures that involve soft power downs.
    – ethan
    Jan 31, 2021 at 7:47

For external USB disks, use

sg_start --stop /dev/sdb

Install using

sudo apt-get install sg3-utils

Works for my WD My Book Essential Disks.


If you right-click the drive's icon and select Safely Remove Drive, that should do it (as already stated, it takes 15 seconds or so).

If you don't have that option, right-click and unmount the drive. Then start Disk Utility; select the drive in the left panel; select Safe Removal in the right panel. Again, wait 15 seconds or so. (Alternatively, you can Unmount Volume from Disk Utility before Safe Removal if that is easier for you.)


It worked in xfce4 on Fedora 17 for powering down external hard disk:

udisks --detach /dev/sdc

Palimpsest used to have power off option in Fedora 14, but not in Fedora 17.

Useful features go out with OS upgrade in both Windows and Linux.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .