power-off
Arranges for the drive to be safely removed and powered off. On the OS
side this includes ensuring that no process is using the drive, then
requesting that in-flight buffers and caches are committed to stable
storage. The exact steps for powering off the drive depends on the
drive itself and the interconnect used. For drives connected through
USB, the effect is that the USB device will be deconfigured followed by
disabling the upstream hub port it is connected to.
Note that as some physical devices contain multiple drives (for example
4-in-1 flash card reader USB devices) powering off one drive may affect
other drives. As such there are not a lot of guarantees associated with
performing this action. Usually the effect is that the drive disappears
as if it was unplugged.
没有弹出 USB 设备的机制。卸载它(在您的情况下
umount /dev/sdg1
并手动删除它。(假设 /dev/sdg1 是 /dev/sdg 上唯一安装的分区)。您可以使用类似命令验证设备上安装了哪些分区lsblk
以及mount | grep sdX
sdX 对应于您的设备的位置(在你的情况下,sdg)。eject
专门用于可移动介质,例如光驱、软盘、磁带、ZIP、JAZ 驱动器,闪存驱动器根本不支持。资料来源:
man eject
我认为在 USB 驱动器的情况下“弹出”意味着卸载和关闭电源,正如某些 GUI 工具(带有弹出符号)所实现的那样。
您可以查看
udisks
和工具udisksctl
。阅读手册
例如,你会发现命令
我觉得
命令可以做你想做的事。在这种情况下,“sdg”中有一个分区
<device>
是/dev/sdg1