I have an external hard drive which attaches to my pc via usb. The drive is formatted for Linux, i.e. ext4 and is used to take backups. It has its own separate power supply. When I switch its power supply on it fires up and mounts automatically which is great. I take backups and then want to power it down. (There is no point in running it when I am not taking or using the backups and anyway it gets hot and consumes power unnecessarily). My question is what is the best and safest procedure for powering it down?

Thank you everybody for all the really helpful answers. I am using Ubuntu 18.04 so will use the GUI option until it disappears in the future. Then, I have saved all the other answers for when I need them! Really appreciate all the time taken to help me out: thank you.

  • 1
    best and safest I don't know; but if using a gui I tend to like hitting the 'power' button in gnome-disks (though as I usually use LXQt I can use the 'removable media/device manager' but you didn't provide tails as to your release of Ubuntu, thus if gnome/unity - hence my suggestion)
    – guiverc
    Aug 3, 2019 at 11:48

4 Answers 4


I use a variant of the previously noted solutions, wrapped in a bash script, and launched from a desktop icon. Since my application is for an external USB drive, I include code to identify the relevant device name based on the specific name of my USB drive (SILICON16GB). The main components of the process are:

# Flush USB drive buffer
# Identify the device name for the SILICON16GB USB drive
usblongname=$(lsblk -l | grep SILICON16GB)
# Unmount the USB drive
udisksctl unmount -b /dev/$usbname
# Power off the USB drive
udisksctl power-off -b /dev/$usbname

Note that the use of the sync command causes the script to wait until any writes to the USB drive have been completed. The script is failsafe in that it does nothing if the drive is already unmounted. More details, and a full listing of the bash script can be found at: https://linuxnorth.wordpress.com/2018/01/25/safely-removing-a-usb-drive-with-a-bash-script/


The GUI way to do this is (in Ubuntu)...

Unmount the mounted disk by clicking on the "eject" icon (Files/Nautilus), as shown below...

enter image description here

Open the Disks application and select "Power Off", as shown below...

enter image description here

  • @user68186 The Disks app can unmount partitions, but it's much more difficult. In 19.04 these options don't exist in a contextual menu... as desktop icons for mounted drives don't exist :-(
    – heynnema
    Aug 3, 2019 at 16:24
  • Thanks for the quick response. I only use LTS versions and didn't realize that the desktop icons went away in 19.04.
    – user68186
    Aug 3, 2019 at 16:31
  • Good to know there's Power Off option in GNOME Disks. But, it's still bad - users should be doing this by default in file manager, otherwise disks might not like hard unplugging while powered on.
    – kravemir
    Feb 7 at 19:53

after umounting the Partitons of your usb harddrive, you can run udisksctl power-off -b /dev/sd?

For ? you have to adapt it to your situation.

example for my backup drive udisksctl power-off -b /dev/sdc

  • partition(s) as there may be more than one mounted at the time. You might also add the umount/unmount details.
    – heynnema
    Aug 3, 2019 at 15:55
  • @heynnema: If you want to nitpick, then why not go all the way? You don't mount / unmount partitions, you mount / unmount filesystems. A partition may not contain a filesystem. A filesystem may not be located on a partition. One partition may contain multiple filesystems. A filesystem may span multiple partitions. Aug 4, 2019 at 7:08
  • @JörgWMittag Not nitpicking... but rather... without re-writing the answer myself... I was giving "nobody" pointers on how they could expand on their answer and make it encompass more variables and provide more information.
    – heynnema
    Aug 4, 2019 at 13:25

I would unmount all mounted partitions on the external drive (maybe only one ext4 partition in your case),

sudo umount mountpoint


sudo umount /dev/sdxn

where mountpoint is the path to the partition you want to unmount and x is the device letter and n the partition number of the partition you want to unmount.

Check that the unmount command finishes successfully and the terminal window returns to prompt.

After the unmount operation(s) buffers are flushed and everything pending is written to the physical location of the drive, and it is safe to power off the external drive.

  • 1
    This doesn't "power down" the drive. Please see my answer for a safer way to do this in Ubuntu.
    – heynnema
    Aug 3, 2019 at 15:34

Not the answer you're looking for? Browse other questions tagged or ask your own question.