Ubuntu – Equivalent to “safely remove hardware” in Windows

driveeject

I had always guessed that hitting the eject button in a file manager would be the equivalent of the Windows "safely remove hardware" function for drives. However I notice that hitting eject for drives in Ubuntu does not actually stop the hard drives from spinning, but in Windows the function causes the drive to come to a complete stop. Is there something else I should be doing before removing drives in Ubuntu? Or is the eject function the correct method for Ubuntu?

Best Answer

In MATE at least it seems clicking the eject button just unmounts the device. To unmount and power off the drive on the command line, you can use udisksctl

First list the drives with lsblk

NAME         MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sdb            8:0    1 15.2G  0 disk 
└─sdb1         8:1    1 15.2G  0 part /media/zanna/4C45-110F
mmcblk0rpmb  179:24   0    4M  0 disk 
mmcblk0boot0 179:8    0    4M  1 disk 
mmcblk0boot1 179:16   0    4M  1 disk 
mmcblk0      179:0    0 29.1G  0 disk 
├─mmcblk0p1  179:1    0  512M  0 part /boot/efi
├─mmcblk0p2  179:2    0 26.7G  0 part /
└─mmcblk0p3  179:3    0    2G  0 part [SWAP]

I want to remove the drive /dev/sdb so I would do

udisksctl unmount -b /dev/sdb1
udisksctl power-off -b /dev/sdb