I own a Seagate Free Agent external hard drive for last 4-5 years. After plugged in and finished with file transfers I will click menu 'Safely remove'. Then it will gracefully shut down itself, stopping spinning of disk inside. I can feel it if touched. Also, power light will be also off.

Recently I bought a new external hard disk, WD Elements. If I issue 'Safely remove' for this hard drive, it just get unmounted, but not powering off itself, also the disks continue spinning, I can feel when touched. I also tried 'Power off the drive' button in 'Disks' application comes with Ubuntu. Then also, it just get unmounted only.

I would like see the WD Elements hard drive gracefully shutdown itself, before I manually unplug it. I assume forcefully unplugging the device before it stops itself may shorten its lifespan.

Is there any other command or program that will help me to do it?


You need an additional package that contains a utility to actually power off the WD as WD does not support Linux out of the box:

sudo apt-get install usdisks2
sudo udisksctl power-off --block-device /dev/XdY

where X and Y are the letters corresponding to your disk.

  • Don't thank me! ;-) If you like my answer, just click the little grey under the "0" now turning it into beautiful green. If you do not like my answer, click on the little grey down-arrow below the 0, and if you really like my answer, click on the little grey checkmark and the little up-arrow... If you have any further questions, go to askubuntu.com/questions/ask – Fabby Mar 24 '15 at 13:26

So far I haven't found a simple alternative to "safely eject" in the file manager, so this is my justification for using command line here.

First , you'd need to find out your external hard-drives device id or block id. Then you can use either udisks or udisksctl to unmount and actually power off the device. I have answered related question some time ago , when just started out with ubuntu, so I suggest you refer to it as well. Basically , i use udisks --unmount /dev/sdb1 && udisks --detach /dev/sdb where sdb1 is the mount-point and sdb is the actual disk.

You can use lsblk and identify it by mount-point and size; on the other hand, you can use udisksctl status. For instance, I have a Sandisk Cruiser usb drive connected right now. The output of the commands is the following: enter image description here

As you can see both report that my usb drive is identified as /dev/sdc. Each time you pugin a usb device it will be identified with different letters, sdb, sdc,sdf and so forth, while sda is always your hard-drive.

So in my case , I would eject the usb with udisks --unmount /dev/sdc1 && udisks --detach /dev/sdc or alternatively with what Fabby suggested. With the one-liner I use, I've noticed that the device id is preserved, i.e, if i eject the usd and reconnect it, it still gives the device sdc name.

TIP: you can use udisksctl status | grep -i wd to show only information for the external hard drive.

Now, here's something I've done purely for fun, but you could find it useful and adapt to your own needs. What if we could write a script to do the safe-ejecting for us ?

We'd need to let the shell know the block id of out external hdd or usb. What would be the output of this command : udisksctl status | grep -i sandisk | xargs echo ? It would be this: SanDisk Cruzer Glide 1.27 2005425573077FA0AA67 sdd, or in other words information about the usb , delimited by spaces, with the device id being last argument, or the 6th one. Here we can use cut command to extract it like so: udisksctl status | grep -i sandisk | xargs echo | cut -d' ' -f6

Of course for you, you'd have to use udisksctl status | grep -i wd | xargs echo and count which element is your block id is, and then use appropriate number on cut -d' ' -fx

Next , I've put together the script remove-usb.sh. Here it is:


DEVICE=$( udisksctl status | grep -i sandisk | xargs echo | cut -d' ' -f6 )

udisks --unmount /dev/$(echo $DEVICE)1 && udisks --detach /dev/$DEVICE

Next, placed it in my /home/user/bin folder, chmod +x /home/user/bin/remove-usb.sh. Don't forget to have that bin folder to be added to your path. Now you can also create a .desktop file or make script executable in the file manager

And here's the script in action enter image description here


Following shell script do the job for me.


DEVICE=$(udisksctl status | grep -i "WD Elements" | xargs echo | cut -d' ' -f6)

udisks --unmount /dev/$(echo $DEVICE)1
sudo udisksctl power-off --block-device /dev/$DEVICE

It is actually combination of ideas from posts of both @Serg and @Fabby.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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