I'm using node-detection
to be notify when a USB
device was plugged in. However I can't seem to find out how to know to which port was it plugged in to, e.g. sdb1, sdc1, etc. Is there a simple way of doing it?
当插入USB设备时,我正在使用节点检测进行通知。但是我似乎无法知道如何知道它插入的端口,例如sdb1,sdc1等。有一种简单的方法吗?
3 个解决方案
#1
2
You can use the drivelist module in addition to the node-detection module, made by the excellent folks at resin.io.
除了由resin.io的优秀人员制作的节点检测模块之外,您还可以使用驱动模块。
The drivelist module lists all connected devices including the mountpoint (path) information. This output is slightly different depending on your operating system. Check the drivelist documentation for more info.
驱动器模块列出所有连接的设备,包括安装点(路径)信息。此输出略有不同,具体取决于您的操作系统。查看驱动程序文档以获取更多信息。
Here's a quick example to find when a removable USB drive is inserted and mounted, and get the mount path.
这是一个快速示例,可以找到插入和安装可移动USB驱动器的时间,并获取安装路径。
From some testing, the usb-detection module fires nearly instantaneously when a device is plugged in, but it takes time for the device to mount. So I am using a setInterval to keep checking if a mountpoint exists. Once I find a mountpoint, I clear the interval.
在某些测试中,usb检测模块在插入设备时几乎立即触发,但设备安装需要一些时间。所以我使用setInterval来检查是否存在mountpoint。找到一个挂载点后,我清除间隔。
// load modules
var usbDetect = require('usb-detection');
const drivelist = require('drivelist');
var checkUSBintervalID;
// This is the listener function for the 'add' event
function addUSBhandler() {
console.log('added event listener for usb ADD');
// Start interval to check if the USB is mounted
checkUSBintervalID = setInterval(function() {
drivelist.list(function(error, drives) {
console.log('listening for USB mount...');
if (error) { throw error; }
// iterate through all drives
for(var d = 0; d < drives.length; d++) {
// if the drive is a removable usb
if(drives[d].system == false) {
// if this drive is mounted
if(drives[d].mountpoints.length > 0) {
console.log('found removable USB');
// the drive is mounted
// do stuff here
// the path is at drives[d].mountpoints[0].path
clearInterval(checkUSBintervalID);
}
}
}
});
}, 1000);
}
// Add listener for when a USB is plugged in
usbDetect.on('add', addUSBhandler);
This answer does not take into account if the USB is inserted and removed before it is mounted. You probably need to add a timeout or something similar. Hoped this helped, and good luck.
如果在安装USB之前插入和拔出USB,则此答案不会考虑。您可能需要添加超时或类似的东西。希望这有所帮助,祝你好运。
#2
1
I think it's not working with node-detection
我认为它不适用于节点检测
Maybe not the best way, but this worked for me:
也许不是最好的方式,但这对我有用:
var shell = require('shelljs');
var watch = require('node-watch');
var tmpUsb;
Array.prototype.contains = function(needle){
for (var i=0; i<this.length; i++)
if (this[i] == needle) return true;
return false;
}
Array.prototype.diff = function(compare) {
return this.filter(function(elem) {return !compare.contains(elem);})
}
getUsb = function() {
this.usbJson = JSON.parse(shell.exec('lsblk --json', {silent:true}).stdout);
var dev = this.usbJson.blockdevices;
var devices = [];
dev.forEach(function(entry) {
entry.children.forEach(function(e) {
devices.push(e.mountpoint);
});
});
return devices;
}
tmpUsb = getUsb();
watch('/dev/disk/by-id', { recursive: true }, function(evt, name) {
var curr = getUsb();
var add = curr.diff(tmpUsb);
var rem = tmpUsb.diff(curr);
if(add.length > 0) {
console.log("ADD > " + add);
}
if(rem.length > 0) {
console.log("REM > " + rem);
}
tmpUsb = curr;
});
Please add in your question what your output is. What code did you try....
请在您的问题中添加您的输出。你尝试了什么代码....
#3
0
I don't know about node.js bindings, but using external udevadm
tool the info is exposed:
我不知道node.js绑定,但使用外部udevadm工具显示信息:
$ udevadm monitor
monitor will print the received events for:
UDEV - the event which udev sends out after rule processing
KERNEL - the kernel uevent
KERNEL[766928.886896] add /devices/pci0000:00/0000:00:10.0/usb5/5-1 (usb)
KERNEL[766928.888766] add /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0 (usb)
UDEV [766929.091194] add /devices/pci0000:00/0000:00:10.0/usb5/5-1 (usb)
KERNEL[766930.777996] add /module/usb_storage (module)
UDEV [766930.780203] add /module/usb_storage (module)
KERNEL[766930.781054] add /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4 (scsi)
KERNEL[766930.781241] add /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/scsi_host/host4 (scsi_host)
KERNEL[766930.781370] add /bus/usb/drivers/usb-storage (drivers)
UDEV [766930.782320] add /bus/usb/drivers/usb-storage (drivers)
KERNEL[766931.092511] add /module/uas (module)
UDEV [766931.092584] add /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0 (usb)
KERNEL[766931.092608] add /bus/usb/drivers/uas (drivers)
UDEV [766931.093550] add /module/uas (module)
UDEV [766931.094000] add /bus/usb/drivers/uas (drivers)
UDEV [766931.094305] add /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4 (scsi)
UDEV [766931.095737] add /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/scsi_host/host4 (scsi_host)
KERNEL[766931.807635] add /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0 (scsi)
KERNEL[766931.807770] add /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0 (scsi)
KERNEL[766931.807901] add /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/scsi_disk/4:0:0:0 (scsi_disk)
KERNEL[766931.807995] add /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/scsi_device/4:0:0:0 (scsi_device)
KERNEL[766931.809543] add /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/scsi_generic/sg2 (scsi_generic)
KERNEL[766931.809605] add /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/bsg/4:0:0:0 (bsg)
UDEV [766931.811736] add /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0 (scsi)
KERNEL[766931.812771] add /devices/virtual/bdi/8:16 (bdi)
UDEV [766931.815246] add /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0 (scsi)
UDEV [766931.815908] add /devices/virtual/bdi/8:16 (bdi)
UDEV [766931.818228] add /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/scsi_disk/4:0:0:0 (scsi_disk)
UDEV [766931.819748] add /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/bsg/4:0:0:0 (bsg)
UDEV [766931.821506] add /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/scsi_device/4:0:0:0 (scsi_device)
UDEV [766931.821894] add /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/scsi_generic/sg2 (scsi_generic)
KERNEL[766931.895701] add /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/block/sdb (block)
KERNEL[766931.895807] add /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/block/sdb/sdb1 (block)
KERNEL[766931.895879] add /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/block/sdb/sdb2 (block)
UDEV [766933.474661] add /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/block/sdb (block)
UDEV [766933.566443] add /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/block/sdb/sdb2 (block)
UDEV [766933.658413] add /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/block/sdb/sdb1 (block)
KERNEL[766942.802911] remove /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/bsg/4:0:0:0 (bsg)
KERNEL[766942.804048] remove /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/scsi_generic/sg2 (scsi_generic)
KERNEL[766942.804163] remove /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/scsi_device/4:0:0:0 (scsi_device)
KERNEL[766942.804246] remove /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/scsi_disk/4:0:0:0 (scsi_disk)
KERNEL[766942.804338] remove /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/block/sdb/sdb2 (block)
KERNEL[766942.804426] remove /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/block/sdb/sdb1 (block)
KERNEL[766942.804518] remove /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/block/sdb (block)
KERNEL[766942.804590] remove /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0 (scsi)
UDEV [766942.806838] remove /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/bsg/4:0:0:0 (bsg)
UDEV [766942.807543] remove /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/scsi_generic/sg2 (scsi_generic)
UDEV [766942.809181] remove /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/scsi_disk/4:0:0:0 (scsi_disk)
UDEV [766942.809410] remove /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/scsi_device/4:0:0:0 (scsi_device)
UDEV [766942.812382] remove /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/block/sdb/sdb1 (block)
UDEV [766942.812545] remove /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/block/sdb/sdb2 (block)
UDEV [766942.814711] remove /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/block/sdb (block)
UDEV [766942.815300] remove /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0 (scsi)
KERNEL[766942.816341] remove /devices/virtual/bdi/8:16 (bdi)
KERNEL[766942.816384] remove /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0 (scsi)
UDEV [766942.817716] remove /devices/virtual/bdi/8:16 (bdi)
UDEV [766942.819175] remove /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0 (scsi)
KERNEL[766942.864803] remove /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/scsi_host/host4 (scsi_host)
KERNEL[766942.864891] remove /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4 (scsi)
KERNEL[766942.865168] remove /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0 (usb)
KERNEL[766942.866960] remove /devices/pci0000:00/0000:00:10.0/usb5/5-1 (usb)
UDEV [766942.867670] remove /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/scsi_host/host4 (scsi_host)
UDEV [766942.868469] remove /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4 (scsi)
UDEV [766942.869291] remove /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0 (usb)
UDEV [766942.870791] remove /devices/pci0000:00/0000:00:10.0/usb5/5-1 (usb)
Some notes:
一些说明:
- There can be more than one partition on a USB stick, or it may have a filesystem directly without partitions.
- USB记忆棒上可以有多个分区,也可以直接没有分区的文件系统。
- You probably don't need to monitor for USB devices specifically, just any block device perhaps?
- 您可能不需要专门监控USB设备,也许只需要监控任何块设备?
- This isn't doing any filtering, you'll get a lot of unrelated events yet.
- 这不是任何过滤,你会得到很多无关的事件。
#1
2
You can use the drivelist module in addition to the node-detection module, made by the excellent folks at resin.io.
除了由resin.io的优秀人员制作的节点检测模块之外,您还可以使用驱动模块。
The drivelist module lists all connected devices including the mountpoint (path) information. This output is slightly different depending on your operating system. Check the drivelist documentation for more info.
驱动器模块列出所有连接的设备,包括安装点(路径)信息。此输出略有不同,具体取决于您的操作系统。查看驱动程序文档以获取更多信息。
Here's a quick example to find when a removable USB drive is inserted and mounted, and get the mount path.
这是一个快速示例,可以找到插入和安装可移动USB驱动器的时间,并获取安装路径。
From some testing, the usb-detection module fires nearly instantaneously when a device is plugged in, but it takes time for the device to mount. So I am using a setInterval to keep checking if a mountpoint exists. Once I find a mountpoint, I clear the interval.
在某些测试中,usb检测模块在插入设备时几乎立即触发,但设备安装需要一些时间。所以我使用setInterval来检查是否存在mountpoint。找到一个挂载点后,我清除间隔。
// load modules
var usbDetect = require('usb-detection');
const drivelist = require('drivelist');
var checkUSBintervalID;
// This is the listener function for the 'add' event
function addUSBhandler() {
console.log('added event listener for usb ADD');
// Start interval to check if the USB is mounted
checkUSBintervalID = setInterval(function() {
drivelist.list(function(error, drives) {
console.log('listening for USB mount...');
if (error) { throw error; }
// iterate through all drives
for(var d = 0; d < drives.length; d++) {
// if the drive is a removable usb
if(drives[d].system == false) {
// if this drive is mounted
if(drives[d].mountpoints.length > 0) {
console.log('found removable USB');
// the drive is mounted
// do stuff here
// the path is at drives[d].mountpoints[0].path
clearInterval(checkUSBintervalID);
}
}
}
});
}, 1000);
}
// Add listener for when a USB is plugged in
usbDetect.on('add', addUSBhandler);
This answer does not take into account if the USB is inserted and removed before it is mounted. You probably need to add a timeout or something similar. Hoped this helped, and good luck.
如果在安装USB之前插入和拔出USB,则此答案不会考虑。您可能需要添加超时或类似的东西。希望这有所帮助,祝你好运。
#2
1
I think it's not working with node-detection
我认为它不适用于节点检测
Maybe not the best way, but this worked for me:
也许不是最好的方式,但这对我有用:
var shell = require('shelljs');
var watch = require('node-watch');
var tmpUsb;
Array.prototype.contains = function(needle){
for (var i=0; i<this.length; i++)
if (this[i] == needle) return true;
return false;
}
Array.prototype.diff = function(compare) {
return this.filter(function(elem) {return !compare.contains(elem);})
}
getUsb = function() {
this.usbJson = JSON.parse(shell.exec('lsblk --json', {silent:true}).stdout);
var dev = this.usbJson.blockdevices;
var devices = [];
dev.forEach(function(entry) {
entry.children.forEach(function(e) {
devices.push(e.mountpoint);
});
});
return devices;
}
tmpUsb = getUsb();
watch('/dev/disk/by-id', { recursive: true }, function(evt, name) {
var curr = getUsb();
var add = curr.diff(tmpUsb);
var rem = tmpUsb.diff(curr);
if(add.length > 0) {
console.log("ADD > " + add);
}
if(rem.length > 0) {
console.log("REM > " + rem);
}
tmpUsb = curr;
});
Please add in your question what your output is. What code did you try....
请在您的问题中添加您的输出。你尝试了什么代码....
#3
0
I don't know about node.js bindings, but using external udevadm
tool the info is exposed:
我不知道node.js绑定,但使用外部udevadm工具显示信息:
$ udevadm monitor
monitor will print the received events for:
UDEV - the event which udev sends out after rule processing
KERNEL - the kernel uevent
KERNEL[766928.886896] add /devices/pci0000:00/0000:00:10.0/usb5/5-1 (usb)
KERNEL[766928.888766] add /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0 (usb)
UDEV [766929.091194] add /devices/pci0000:00/0000:00:10.0/usb5/5-1 (usb)
KERNEL[766930.777996] add /module/usb_storage (module)
UDEV [766930.780203] add /module/usb_storage (module)
KERNEL[766930.781054] add /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4 (scsi)
KERNEL[766930.781241] add /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/scsi_host/host4 (scsi_host)
KERNEL[766930.781370] add /bus/usb/drivers/usb-storage (drivers)
UDEV [766930.782320] add /bus/usb/drivers/usb-storage (drivers)
KERNEL[766931.092511] add /module/uas (module)
UDEV [766931.092584] add /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0 (usb)
KERNEL[766931.092608] add /bus/usb/drivers/uas (drivers)
UDEV [766931.093550] add /module/uas (module)
UDEV [766931.094000] add /bus/usb/drivers/uas (drivers)
UDEV [766931.094305] add /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4 (scsi)
UDEV [766931.095737] add /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/scsi_host/host4 (scsi_host)
KERNEL[766931.807635] add /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0 (scsi)
KERNEL[766931.807770] add /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0 (scsi)
KERNEL[766931.807901] add /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/scsi_disk/4:0:0:0 (scsi_disk)
KERNEL[766931.807995] add /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/scsi_device/4:0:0:0 (scsi_device)
KERNEL[766931.809543] add /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/scsi_generic/sg2 (scsi_generic)
KERNEL[766931.809605] add /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/bsg/4:0:0:0 (bsg)
UDEV [766931.811736] add /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0 (scsi)
KERNEL[766931.812771] add /devices/virtual/bdi/8:16 (bdi)
UDEV [766931.815246] add /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0 (scsi)
UDEV [766931.815908] add /devices/virtual/bdi/8:16 (bdi)
UDEV [766931.818228] add /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/scsi_disk/4:0:0:0 (scsi_disk)
UDEV [766931.819748] add /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/bsg/4:0:0:0 (bsg)
UDEV [766931.821506] add /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/scsi_device/4:0:0:0 (scsi_device)
UDEV [766931.821894] add /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/scsi_generic/sg2 (scsi_generic)
KERNEL[766931.895701] add /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/block/sdb (block)
KERNEL[766931.895807] add /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/block/sdb/sdb1 (block)
KERNEL[766931.895879] add /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/block/sdb/sdb2 (block)
UDEV [766933.474661] add /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/block/sdb (block)
UDEV [766933.566443] add /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/block/sdb/sdb2 (block)
UDEV [766933.658413] add /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/block/sdb/sdb1 (block)
KERNEL[766942.802911] remove /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/bsg/4:0:0:0 (bsg)
KERNEL[766942.804048] remove /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/scsi_generic/sg2 (scsi_generic)
KERNEL[766942.804163] remove /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/scsi_device/4:0:0:0 (scsi_device)
KERNEL[766942.804246] remove /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/scsi_disk/4:0:0:0 (scsi_disk)
KERNEL[766942.804338] remove /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/block/sdb/sdb2 (block)
KERNEL[766942.804426] remove /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/block/sdb/sdb1 (block)
KERNEL[766942.804518] remove /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/block/sdb (block)
KERNEL[766942.804590] remove /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0 (scsi)
UDEV [766942.806838] remove /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/bsg/4:0:0:0 (bsg)
UDEV [766942.807543] remove /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/scsi_generic/sg2 (scsi_generic)
UDEV [766942.809181] remove /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/scsi_disk/4:0:0:0 (scsi_disk)
UDEV [766942.809410] remove /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/scsi_device/4:0:0:0 (scsi_device)
UDEV [766942.812382] remove /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/block/sdb/sdb1 (block)
UDEV [766942.812545] remove /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/block/sdb/sdb2 (block)
UDEV [766942.814711] remove /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0/block/sdb (block)
UDEV [766942.815300] remove /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0/4:0:0:0 (scsi)
KERNEL[766942.816341] remove /devices/virtual/bdi/8:16 (bdi)
KERNEL[766942.816384] remove /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0 (scsi)
UDEV [766942.817716] remove /devices/virtual/bdi/8:16 (bdi)
UDEV [766942.819175] remove /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/target4:0:0 (scsi)
KERNEL[766942.864803] remove /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/scsi_host/host4 (scsi_host)
KERNEL[766942.864891] remove /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4 (scsi)
KERNEL[766942.865168] remove /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0 (usb)
KERNEL[766942.866960] remove /devices/pci0000:00/0000:00:10.0/usb5/5-1 (usb)
UDEV [766942.867670] remove /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4/scsi_host/host4 (scsi_host)
UDEV [766942.868469] remove /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0/host4 (scsi)
UDEV [766942.869291] remove /devices/pci0000:00/0000:00:10.0/usb5/5-1/5-1:1.0 (usb)
UDEV [766942.870791] remove /devices/pci0000:00/0000:00:10.0/usb5/5-1 (usb)
Some notes:
一些说明:
- There can be more than one partition on a USB stick, or it may have a filesystem directly without partitions.
- USB记忆棒上可以有多个分区,也可以直接没有分区的文件系统。
- You probably don't need to monitor for USB devices specifically, just any block device perhaps?
- 您可能不需要专门监控USB设备,也许只需要监控任何块设备?
- This isn't doing any filtering, you'll get a lot of unrelated events yet.
- 这不是任何过滤,你会得到很多无关的事件。