Is there any way to turn off a USB HDD manually?

Solution 1:

Try this:

udisksctl unmount -b /dev/sdXY
udisksctl power-off -b /dev/sdX

on Linux Mint or Ubuntu

Solution 2:

Running hdparm -y /dev/sdb as root will cause the disk to stop spinning. If anything access the disk, it will spin up again.

The man page suggest this is only useful for IDE drives. However I have tested that it does work with a USB drive attached to a Dell running 14.04. The man page says the command will usually cause the drive to spin down, which suggests some drives exist which will not spin down when this command is issued.

Solution 3:

Try the Disks utility - that should be on your menu somewhere (in my case under Accessories). You can also launch it from a terminal by running

gnome-disks

... then select the disk and you will see a power button at top-right of the window, with tooltip "Power off the drive".

Solution 4:

If your desktop does something fishy, you cal always fallback on the terminal.

sudo umount /dev/sdXY
# (this will umount, it will complain on opened files, if so lsof and see which ones.)
sudo sync  
# ( this flushes all buffers to disk. It will ensure that no data is lingering in ram.)
sudo eject /dev/sdX
# ( this works on dvd/cds and some, not all usb devices, it detaches the device from the port. Some devices "get smart" and try to reset and readd themselves to the disk, however all caches are clean and safe to unplug).

On the other hand, once a device is unidentified as a block device on USB, then you can use sdparm or hdparm on that device to park the heads if so desired, however using such tools will not flash buffers. And if you forget that the device is sleeping and yank the power, then you can corrupt your data.