It's easy to get a Linux kernel that supports USB now. But that's only part of what you need in order to use USB; the rest of the operating environment needs updates, of various types, to make it usable. At this writing, only a few GNU/Linux distributions support even statically configured USB ... yet USB is about hotplugging and dynamic configuration. What does your Linux system need to really run USB?
The short version of the rest of this document is this: download and install the Linux-USB tools, so that USB is fully set up and so that you can use your kernel HOTPLUG support.
The assumption here is that Plug'n'Play operation is the design center for USB on Linux. Some sites may still prefer manual administration, perhaps to learn more about how USB runs under Linux or because that's what their GNU/Linux distribution supports. For example, several distributions have begun to ship with partial (no hotplugging) USB support enabled, with their own /etc/rc scripts:
USB initialization scripts need to interact with any other tools (and hidden configuration data) in use. This of course includes working with all combinations of kernel configuration options (including being more or less modular) and hardware setups. It may also affect configuration of other subsystems (e.g. to make a professional USB synthesizer the default, not the midi on the cheap sound card). So it may be to your advantage to work with the USB tools in your Linux distribution ... keeping in mind that all the tools are in early stages, and may not yet support what you need!
At this writing only the Linux-USB "usbd tools" (next) support USB hotplugging.
The current software is at the linux-hotplug project site. There's an RPM version (soon, APT), and also a tarball (with installation instructions) if you need that. This includes USB hotplugging support, and also handles PCI.
To use USB in anything like a natural way, Linux needs a "USB Daemon", or USBD. A USBD reacts to users adding and removing devices, setting things up so they work correctly. That is, it handles essential parts of "Hot Plug" processing. It has two parts:
The same approach can work with other kernel subsystems that
need to dynamically react to device addition and removal.
/sbin/hotplug program (typically a shell script;
see the reference code in CVS above)
handles USB the same way it can handle other types of hotplug events.
The Linux-USB Tools package provides an implementation of a USB Hotplug agent; more intelligent implementations will likely appear. Documentation exists. The most recent release leverages USB "modutils" support with Linux 2.4.0 kernel series. (The expectation is that such support will replace earlier support that relied exclusively on driver configuration scripts.)
The only currently supported USB Daemon is the Kernel USB Daemon. You get it when you enable HOTPLUG with USB; it is "light weight" in that it doesn't require "usbdevfs" support (a design requirement) and adds only a very small amount of kernel code. (Previous daemons required "usbdevfs" and a user mode process scanning it for changes. That was a much larger system footprint.) Most of the work is punted to user mode, by invoking a user mode helper program (/sbin/hotplug by default) that knows how to find the USB policy agent that does the real work. The modutils support is targeted at 2.4.0 but the 2.2.18 kernel also works.
When you boot a kUSBD-enabled kernel,
you will see a file
if you're running with procfs (as you probably should be).
It will name the program
/sbin/hotplug by default.
Whenever a USB device is added or removed,
that program will be invoked (if it exists).
To change the program name, write to /proc/sys/kernel/hotplug.
Use the hotplug script and USB policy agent
provided with the Linux-USB tools (see above).
If you use kUSBD, the Linux-USBD scripts can be a single-download solution for "USB Plug'n'Play". If you're using a 2.4 kernel with USB modutils support, you can make do with just the "/sbin/hotplug" script, which handles most module loading and driver-specific setup tasks using only common /sbin programs. You can install a more functional policy agent in /etc/hotplug/usb.agent if you prefer.
The first USB Daemon to fully support USB hotplugging was the Java USB Daemon (jUSBD); it has since been desupported in favor of the kernel support (which doesn't require usbdevfs). This relied on /etc/usb/policy scripts, which were then used as kUSBD policy agents.
Thomas Sailer provided the first usbdevfs based daemon with his usbd 0.1 release. It wasn't very flexible about policies.
Recently, another usbdevfs based effort was reported: the USB Manager defines a custom configuration file and driver database format which somewhat resembles the PCMCIA support. It provides a usbdevfs based notification service.
A devfs based prototype required an experimental usbdevfs-to-devfs merge patch (not part of Linux 2.4); mostly it's listed here for historical knowledge. It successfully invoked the /etc/usb/policy scripts to cause driver loading and configuration.
There are several "USB View" tools available; for example, Corel Linux bundles one version, another is written in Java/Swing. The key difference between those and most shell script listers ("usbtree" etc) is just that they automatically rescan, like a USBD.
It's worth mentioning that Microsoft documentation uses the term "USBD" to refer to a shared library that is part of the Win32 USB device driver API. Try to avoid being confused by that; on Linux, that "d" suffix normally indicates a "daemon".