linux系统怎么关闭usb端口,开启/关闭USB端口

udisksctl有power-off标志,建议您将其与

unmount

来自man udisksctl:

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

演示版

这是我卸载USB Jumpdrive,然后关闭电源

testdir:$ lsusb

Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Bus 001 Device 009: ID 154b:007a PNY

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

testdir:$ lsblk

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT

sda 8:0 0 111.8G 0 disk

└─sda1 8:1 0 111.8G 0 part /

sdb 8:16 1 30G 0 disk

└─sdb1 8:17 1 30G 0 part /media/xieerqi/6A32C4555E1C5B4D

sr0 11:0 1 1024M 0 rom

testdir:$ udisksctl unmount -b /dev/sdb1 && udisksctl power-off -b /dev/sdb1

Unmounted /dev/sdb1.

testdir:$ lsusb

Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

testdir:$ lsblk

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT

sda 8:0 0 111.8G 0 disk

└─sda1 8:1 0 111.8G 0 part /

sr0 11:0 1 1024M 0 rom

testdir:$

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值