首先,您需要使用规则来检测USB存储设备
/etc/udev/rules.d/10-usbmount.rules:
KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="usb", RUN+="/usr/bin/usbdevinserted"
这将运行我们的自定义可执行shell脚本
/usr/bin/usbdevinserted:
#!/bin/bashset 2>&1 >> /tmp/usbdevinfo
此示例脚本转储您需要知道找到哪个设备的环境变量,例如:
DEVlinkS='/dev/disk/by-id/usb-Generic_USB_Flash_Disk-0:0 /dev/disk/by-path/pci-0000:00:13.2-usb-0:2:1.0-scsi-0:0:0:0'DEVNAME=/dev/sdkDEVPATH=/devices/pci0000:00/0000:00:13.2/usb2/2-2/2-2:1.0/host29/target29:0:0/29:0:0:0/block/sdkDEVTYPE=diskID_BUS=usbID_FS_TYPE=ID_INSTANCE=0:0ID_MODEL=USB_Flash_DiskID_MODEL_ENC='USBx20Flashx20Diskx20x20'ID_MODEL_ID=9380ID_PART_TABLE_TYPE=dosID_PART_TABLE_UUID=61d1df0bID_PATH=pci-0000:00:13.2-usb-0:2:1.0-scsi-0:0:0:0ID_PATH_TAG=pci-0000_00_13_2-usb-0_2_1_0-scsi-0_0_0_0ID_REVISION=7.76ID_SERIAL=Generic_USB_Flash_Disk-0:0ID_TYPE=diskID_USB_DRIVER=usb-storageID_USB_INTERFACES=:080650:ID_USB_INTERFACE_NUM=00ID_VENDOR=GenericID_VENDOR_ENC='Genericx20'ID_VENDOR_ID=058fMAJOR=8MINOR=160SUBSYSTEM=block
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)