Turn off (spin down) external (USB) HDD on Linux

16,314

Short lookup in gnome-disk-utility repo code, and:

udisksctl power-off -b /dev/sdX

In ArchLinux, /usr/bin/udisksctl is owned by udisks2 package.

Share:
16,314

Related videos on Youtube

Veelkoov
Author by

Veelkoov

Updated on September 18, 2022

Comments

  • Veelkoov
    Veelkoov almost 2 years

    I have an external HDD connected through USB. There is that Gnome utility called "Disks". When working the disk is on the list on the left. If I click on "turn off" button, the disk disappear from the list and is no longer in lsusb output, and - most important - spins down, turning off.

    What command(s) must I invoke from a script to turn off disk like that?

    sudo hdparm -Y /dev/sdc
    

    gives

    /dev/sdc:
     issuing sleep command
    SG_IO: bad/missing sense data, sb[]:  SOME HEX STUFF
    

    Screenshot from Disks

  • John Hunt
    John Hunt over 3 years
    Will this persist over reboots?
  • Veelkoov
    Veelkoov over 3 years
    I'm far from being an expert here, however I'm not sure if you can suppress the USB device power-up during the machine start (that sounds like some BIOS-y thing). However if powering down the device during system boot is something acceptable, udev might help (once again: no experience here).