Using the USB Host port
The USB Host device driver exposes the connected devices through the file system at /dev/bus/usb/.
Linux identifies USB devices as soon as they are plugged in. Depending on the log level, the serial console may display a message reporting that the USB device has been plugged in. For example, plugging in a USB memory stick displays this message:
sd 1:0:0:0: [sda] 1970176 512-byte logical blocks: (1.00 GB/962 MiB) platform fixedregulator.25: Driver reg-fixed-voltage requests probe deferral sd 1:0:0:0: [sda] Write Protect is off sd 1:0:0:0: [sda] Mode Sense: 0b 00 00 08 sd 1:0:0:0: [sda] No Caching mode page found sd 1:0:0:0: [sda] Assuming drive cache: write through sd 1:0:0:0: [sda] No Caching mode page found sd 1:0:0:0: [sda] Assuming drive cache: write through sda: sda1 sd 1:0:0:0: [sda] No Caching mode page found sd 1:0:0:0: [sda] Assuming drive cache: write through sd 1:0:0:0: [sda] Attached SCSI removable disk FAT-fs (sda1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
If no message is displayed on the console, you can view all the system messages by printing the contents of the system log file:
# cat /var/log/messages
To get a list of the connected USB devices on the USB Host port, use the command lsusb:.
# lsusb Bus 001 Device 004: ID 0781:5530 SanDisk Corp. Cruzer Bus 001 Device 002: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
To get more detailed information on the connected USB device, use
# lsusb -D /dev/bus/usb/001/004
where the first numbered folder corresponds to the bus number and the second to the device number.
USB memory sticks
Linux automatically mounts USB memory sticks' partitions as /media/sdxN, where x is a letter and N the index of the partition (starting at 1).
If Linux does not automatically mount a partition, you can mount it manually. Use the mount command, passing the corresponding file system type with -t option and the mount point folder; for example, for a FAT32 file system:
# mkdir /media/myusb # mount -t vfat /dev/sda1 /media/myusb
Other USB input devices
Other USB input devices, such as a mouse or a keyboard, can be used immediately after being connected. For example, connect a keyboard to a USB connector. Then, run the following command to dump the keyboard key events:
# hexdump /dev/input/event0