Se você deseja detectar como um dispositivo USB está sendo carregado, com excelente granularidade, aqui estão (2) maneiras:
udevadm monitor
: Isso mostrará o dispositivo USB que está sendo carregado conforme o barramento USB o vê .
udevadm
faz parte do pacote padrão udev
no 18.04 LTS; nao precisa instalar.
Execute udevadm monitor
ANTES de inserir o dispositivo USB.
Saída de amostra carregando uma unidade flash USB mostrada abaixo. Pule para a última linha e você pode até ver qual dispositivo ele carregou ( sda1 ):
udevadm monitor
monitor will print the received events for:
UDEV - the event which udev sends out after rule processing
KERNEL - the kernel uevent
KERNEL[969.010067] add /devices/pci0000:00/0000:00:14.0/usb1/1-1 (usb)
KERNEL[969.010367] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0 (usb)
KERNEL[969.018769] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0 (scsi)
KERNEL[969.018849] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/scsi_host/host0 (scsi_host)
KERNEL[969.018934] bind /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0 (usb)
KERNEL[969.019049] bind /devices/pci0000:00/0000:00:14.0/usb1/1-1 (usb)
UDEV [969.024995] add /devices/pci0000:00/0000:00:14.0/usb1/1-1 (usb)
UDEV [969.031390] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0 (usb)
UDEV [969.036362] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0 (scsi)
UDEV [969.041258] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/scsi_host/host0 (scsi_host)
UDEV [969.046202] bind /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0 (usb)
UDEV [969.051734] bind /devices/pci0000:00/0000:00:14.0/usb1/1-1 (usb)
KERNEL[970.051706] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0 (scsi)
KERNEL[970.052068] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0/0:0:0:0 (scsi)
KERNEL[970.052215] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0/0:0:0:0/scsi_disk/0:0:0:0 (scsi_disk)
KERNEL[970.052435] bind /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0/0:0:0:0 (scsi)
KERNEL[970.052585] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0/0:0:0:0/scsi_device/0:0:0:0 (scsi_device)
KERNEL[970.052774] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0/0:0:0:0/scsi_generic/sg0 (scsi_generic)
KERNEL[970.052963] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0/0:0:0:0/bsg/0:0:0:0 (bsg)
UDEV [970.060833] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0 (scsi)
KERNEL[970.061634] add /devices/virtual/bdi/8:0 (bdi)
UDEV [970.069006] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0/0:0:0:0 (scsi)
UDEV [970.071467] add /devices/virtual/bdi/8:0 (bdi)
UDEV [970.075852] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0/0:0:0:0/scsi_disk/0:0:0:0 (scsi_disk)
KERNEL[970.079839] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0/0:0:0:0/block/sda (block)
KERNEL[970.079989] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0/0:0:0:0/block/sda/sda1 (block)
UDEV [970.083556] bind /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0/0:0:0:0 (scsi)
UDEV [970.091288] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0/0:0:0:0/scsi_device/0:0:0:0 (scsi_device)
UDEV [970.091755] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0/0:0:0:0/scsi_generic/sg0 (scsi_generic)
UDEV [970.106807] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0/0:0:0:0/bsg/0:0:0:0 (bsg)
UDEV [970.339976] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0/0:0:0:0/block/sda (block)
UDEV [970.519549] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0/0:0:0:0/block/sda/sda1 (block)
.
dmesg
(que imprime o buffer de anel do Kernel) também oferece uma visibilidade granular do carregamento do seu dispositivo USB.
No entanto, dmesg
ao contrário do que udevadm monitor
mostra como carregar o seu dispositivo USB externo da perspectiva do Kernel
Amostra produzida a partir deste dmesg
momento a partir de uma unidade de CD externa USB - mostrada abaixo. O " 1-2 " refere-se à sua 'localização no barramento USB: Primeiro barramento, segunda porta. Se eu tivesse conectado a unidade de CD à outra porta, ela teria relatado " 1-1 ":
[ 55.296482] usb 1-2: new high-speed USB device number 4 using xhci_hcd
[ 55.453715] usb 1-2: New USB device found, idVendor=1c6b, idProduct=a222
[ 55.453730] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 55.453740] usb 1-2: Product: Mass Storage Device
[ 55.453749] usb 1-2: Manufacturer: USB2.0 External
[ 55.453758] usb 1-2: SerialNumber: 2010100500000000174
[ 55.525860] usb-storage 1-2:1.0: USB Mass Storage device detected
[ 55.527273] scsi host0: usb-storage 1-2:1.0
[ 55.530031] usbcore: registered new interface driver usb-storage
[ 55.545215] usbcore: registered new interface driver uas
[ 56.553073] scsi 0:0:0:0: CD-ROM slimtype eTDU108 1 SL46 PQ: 0 ANSI: 0