USB for Ubuntu |
Desktop Training - Ubuntu 8.04 |
Universal Serial Bus (USB) allows the connection of several types of devices. The peripherals include mice, keyboards, scanners, cameras, modems, sound devices, IrDA, webcams, wireless network cards and printers. The hard devices include thumb drives, external hard drives other network related drives. Using the lsusb command you can see connected devices. Here you can see a mouse connected on the Bus 003 and a Flash Drive on Bus 005. lsusb Bus 007 Device 001: ID 0000:0000 Bus 006 Device 001: ID 0000:0000 Bus 002 Device 001: ID 0000:0000 Bus 001 Device 001: ID 0000:0000 Bus 008 Device 001: ID 0000:0000 Bus 003 Device 003: ID 046d:c50a Logitech, Inc. Bus 003 Device 001: ID 0000:0000 Bus 005 Device 002: ID 0781:5406 SanDisk Corp. Cruzer Micro 4GB Flash Drive Bus 005 Device 001: ID 0000:0000 Bus 004 Device 001: ID 0000:0000
There are three types of USB Controllers. OHCI (Open Host Controller Interface) UHCI (Universal Host Controller Interface) EHCI (Enhanced Host Controller Interface) The OHCI and UHCI Contollers are USB 1.1 devices and capable of only 12 Mps. The EHCI Controllers are USB 2.0 and capable of 480 Mps. In order to get the speeds of EHCI you must connect to EHCI Controllers with EHCI capable cables, devices and hubs. If you do a: cat /proc/modules usb_storage 73664 1 - Live 0xf8a1d000 libusual 19108 1 usb_storage, Live 0xf899b000 usbhid 31872 0 - Live 0xf89fd000 hid 38784 1 usbhid, Live 0xf89f2000 ata_generic 8324 0 - Live 0xf898c000 ata_piix 19588 4 - Live 0xf8977000 floppy 59588 0 - Live 0xf89e2000 ohci1394 33584 0 - Live 0xf897e000 ieee1394 93752 2 sbp2,ohci1394, Live 0xf89ca000 pata_jmicron 7040 0 - Live 0xf8948000 pata_acpi 8320 0 - Live 0xf88c0000 ahci 28420 0 - Live 0xf88f9000 libata 159344 5 ata_generic,ata_piix,pata_jmicron,pata_acpi,ahci, Live 0xf89a2000 scsi_mod 151436 6 sbp2,sg,sd_mod,sr_mod,usb_storage,libata, Live 0xf8922000 ehci_hcd 37900 0 - Live 0xf88ee000 uhci_hcd 27024 0 - Live 0xf88e6000 usbcore 146028 6 usb_storage,libusual,usbhid,ehci_hcd,uhci_hcd, Live 0xf894e000 How Ubuntu Handles USB vs. CentOS One of the major struggles with USB is how to handle these devices when they are plugged in and removed on a frequent basis. Originally Linux devices were static devices. For example, a hard drive was set up when the system booted into a specific runlevel. However, now USB is used so often that the devices are often connected after boot time so a dynamic approach is needed. Ubuntu was one of the first to pioneer Upstart which allows dynamic events to occur so the operating system can respond to those events like the addition of a USB thumb drive.
The runlevel-based SysVinit daemon, typical for CentOS, manages scripts to start in various runlevels by connecting to scripts in the /etc/rcx?.d directories. These are actually links to the actual programs that exit in the /etc/init.d/ directory. The unfortunate situation here is that typically services are started when the runlevel changes are are kept running whether those services are used or not. Upstart has the advantage of starting and stopping services when events occur on the system, like a usb device is attached to the system.
/etc/event.d/rc3 cat rc3 # rc3 - runlevel 3 compatibility # # This task runs the old sysv-rc runlevel 3 (user defined) scripts. It # is usually started by the telinit compatibility wrapper. start on runlevel 3 stop on runlevel [!3] console output script set $(runlevel --set 3 || true) if [ "$1" != "unknown" ]; then PREVLEVEL=$1 RUNLEVEL=$2 export PREVLEVEL RUNLEVEL fi exec /etc/init.d/rc 3 end script
Upstart The runlevel-based SysVinit daemon manages scripts to start in various runlevels by connecting to scripts in the /etc/rcx?.d directories. These are actually links to the actual programs that exit in the /etc/init.d/ directory. The unfortunate situation here is that typically services are started when the runlevel changes are are kept running whether those services are used or not. Upstart has the advantage of starting and stopping services when events occur on the system, like a usb device is attached to the system.
/etc/event.d/rc3
cat rc3 # rc3 - runlevel 3 compatibility # # This task runs the old sysv-rc runlevel 3 (user defined) scripts. It # is usually started by the telinit compatibility wrapper.
start on runlevel 3
stop on runlevel [!3]
console output script set $(runlevel --set 3 || true) if [ "$1" != "unknown" ]; then PREVLEVEL=$1 RUNLEVEL=$2 export PREVLEVEL RUNLEVEL fi
exec /etc/init.d/rc 3 end script
|