How to stop automatic Linux device initialization
Whenever I plug a USB mass storage device into the system, I get uevents like these from the kernel. (as shown in udevadm monitor).
KERNEL[104397.739313] add /devices/pci0000:00/0000:00:14.0/usb3/3-6 (usb) KERNEL[104397.740141] add /devices/pci0000:00/0000:00:14.0/usb3/3-6/3-6:1.0 (usb) KERNEL[104397.740787] add /devices/pci0000:00/0000:00:14.0/usb3/3-6/3-6:1.0/host48 (scsi) KERNEL[104397.741362] add /devices/pci0000:00/0000:00:14.0/usb3/3-6/3-6:1.0/host48/scsi_host/host48 (scsi_host) KERNEL[104399.210661] add /devices/pci0000:00/0000:00:14.0/usb3/3-6/3-6:1.0/host48/target48:0:0 (scsi) KERNEL[104399.211095] add /devices/pci0000:00/0000:00:14.0/usb3/3-6/3-6:1.0/host48/target48:0:0/48:0:0:0 (scsi) KERNEL[104399.211502] add /devices/pci0000:00/0000:00:14.0/usb3/3-6/3-6:1.0/host48/target48:0:0/48:0:0:0/scsi_disk/48:0:0:0 (scsi_disk) KERNEL[104399.211757] add /devices/pci0000:00/0000:00:14.0/usb3/3-6/3-6:1.0/host48/target48:0:0/48:0:0:0/scsi_device/48:0:0:0 (scsi_device) KERNEL[104399.212464] add /devices/pci0000:00/0000:00:14.0/usb3/3-6/3-6:1.0/host48/target48:0:0/48:0:0:0/scsi_generic/sg1 (scsi_generic) KERNEL[104399.212743] add /devices/pci0000:00/0000:00:14.0/usb3/3-6/3-6:1.0/host48/target48:0:0/48:0:0:0/bsg/48:0:0:0 (bsg) KERNEL[104399.215444] add /devices/virtual/bdi/8:16 (bdi) KERNEL[104399.220099] add /devices/pci0000:00/0000:00:14.0/usb3/3-6/3-6:1.0/host48/target48:0:0/48:0:0:0/block/sdb (block) KERNEL[104399.220181] add /devices/pci0000:00/0000:00:14.0/usb3/3-6/3-6:1.0/host48/target48:0:0/48:0:0:0/block/sdb/sdb1 (block)
I need to connect a USB device to KVM as soon as possible, and while udev rules allow me to invoke a script that executes the connection, kernel processing still happens automatically. I want to prevent this from happening. Can this be achieved through udev or other mechanisms?
Actually I remember
this is much simpler than I remember in the new kernel, you just run :
echo '0' > /sys/bus/usb/drivers_autoprobe
Run as root at startup, which prevents the kernel from probing USB devices when they are connected, so they
will only be enumerated if you manually choose to drivers_probe them by writing something to /sys/bus/usb/
This should more or less accomplish what you want, the kernel doesn’t bind any drivers to USB devices, you are free to bind them to your VM later.