Saturday, October 14, 2023

Linux Cheat sheet

1) CLI Equivalent of "Safely Remove Drive"?
fdisk -l | grep Disk | egrep '/sd'

Tested on Ubuntu 20.04

Using udisks2: Detach a disk with udisks2:

udisksctl unmount -b /dev/sdXY
udisksctl power-off -b /dev/sdX
Example if my drive is /dev/sdb1:
udisksctl unmount -b /dev/sdb1
udisksctl power-off -b /dev/sdb
Similarly to above, power-off can be used to detach the drive even if there are no partitions mounted, or no partition was ever mounted:
udisksctl power-off -b /dev/sdb
2)