Straight to the point, the final command line is this:

$ sudo umount -v /dev/sdb?* && udisksctl power-off -b /dev/sdb

Fortunately, you can make shortcut to that long command to be, for example:
$ magic

Explanation goes below. 

There are only 3 steps.

On KDE, more precisely on Dolphin File Manager, press F4 key so you see Konsole appears on its bottom:

 
(Without leaving your file manager, you can do command lines; that's Dolphin)

To understand the command, we learn first where is the location of our partitions:
$ lsblk
 
(From this, we know that they are in /dev/sdb drive denoted as /dev/sdb1 to /dev/sdb10)

Second, we unmount all attached partitions of external hard disk:
$ sudo umount -v /dev/sdb?*


(Unmounting process with detailed progress info)


Third, we safely remove the disk drive:
$ udisksctl power-off --block-device /dev/sdb

(Safely remove the disk drive)

The final result should present you all partitions disappeared and lsblk shows /dev/sdb no more.

 (The lsblk shows only the internal /dev/sda means the external drive /dev/sdb has been removed)

Example above given by considering /dev/sdb as the external disk drive we want to unmount. If lsblk output shows you it's not /dev/sdb but /dev/sdc instead, then use /dev/sdc. And so on.

See? Nothing hard.

Important notes explained below.
  • 1) GNU/Linux OS reads every disk drive attached in special identifier, like, /dev/sdb or /dev/sdc. To know them, use lsblk command. 
  • 2) The OS reads every partition with number following its disk drive identifier, like, /dev/sdb1 or /dev/sdb2, which is a partition inside /dev/sdb disk drive.
  • 3)  
  • 4) The umount and udisksctl commands work with special identifier of partitions and disk drives, respectively.
  • 5) The -v option of umount command means verbose that is to show the process currently being done. 
  • 6) The && sign means making a combination of two commands.

Making short version described below.

To make such long command short, you simply need to create an equation, that is in the .bashrc file of yours. Please be aware that this example is limited to /dev/sdb only, so this is not perfect, and you are free to learn more about this.

1) Edit it with editor:
$ nano ~/.bashrc

2) Scroll down.

3) Write this as new line at bottom:
alias magic="sudo umount -v /dev/sdb?* && udisksctl power-off -b /dev/sdb"

4) Save:
Ctrl+O

5) Exit:
Ctrl+X

6) Try it out:
$ magic

Enjoy!


This article is licensed under CC BY-SA 3.0.


, , , , ,