如何使用 udev 获取设备的 uuid
我想要获取 USB 大容量存储设备的挂载节点,例如 /media/its-uuid 在pyudev中,Device类有一些通用属性,但没有uuid或挂载节点。
怎么做
谢谢帮助
I want get the mount node of an usb mass-storage device, like /media/its-uuid
in pyudev, class Device has some general attributes, but not uuid or mount node.
how to do it
thanks help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 pyudev,每个设备对象为其属性提供类似字典的接口。您可以使用
device.keys()
列出它们,例如块设备的UUID是dev['ID_FS_UUID']
。With pyudev, each device object provides a dictionary-like interface for its attributes. You can list them all with
device.keys()
, e.g. UUID is for block devices isdev['ID_FS_UUID']
.这将打印当前插入的每个 USB 闪存盘的 UUID 及其设备节点:
This will print the UUID of every USB flash disk currently plugged in along with its device node: