Se vuoi rilevare come viene caricato un dispositivo USB, con un'eccellente granularità, ecco (2) modi:
udevadm monitor
: Questo ti mostrerà il dispositivo USB che viene caricato come lo vede il bus USB .
udevadm
fa parte del pacchetto predefinito udev
su 18.04 LTS; non è necessario installarlo.
Eseguire udevadm monitor
PRIMA di inserire il dispositivo USB tuttavia.
Uscita del campione che carica un'unità flash USB mostrata di seguito. Passa all'ultima riga e puoi persino vedere quale dispositivo ha caricato ( 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
(che stampa il buffer dell'anello del kernel) ti darà anche una visibilità granulare sul caricamento del tuo dispositivo USB.
Tuttavia, dmesg
al contrario di udevadm monitor
mostra come caricare il dispositivo USB esterno dal punto di vista del kernel
Uscita campione da dmesg
questo momento da un'unità CD esterna USB- mostrata di seguito. " 1-2 " si riferisce alla sua posizione sul bus USB: primo bus, seconda porta. Se avessi collegato l'unità CD all'altra porta, avrebbe riportato " 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