How to find USB devices in Linux?


Page 1 of 2 12 LastLast
Results 1 to 15 of 17

Thread: How to find USB devices in Linux?

  1. #1
    Join Date
    Nov 2006
    Posts
    49

    How to find USB devices in Linux?

    I have yet to plug a USB device into any of our Ubuntu machines and have the computer immediately recognize it and put up an icon.

    I would like to better understand what is happening within Linux with USB devices. If one gives the terminal command lsusb -v , a lot of information comes up (example quoted from such output for 'Bus 001 Device 001...below) but I am unsure what much of it means. I assume that some of it refers to the bus whether something is plugged in or not, and other of it refers to the device that is plugged in.

    I also assume that at bootup Linux first sets up some sort of communications with the USB ports so that if anything gets plugged in, the presence of the device should be recognized.

    Then presumeably Linux tries to figure out what it is, and if successful, somehow allow user accessability/use of the device.

    So if a user wants to confirm that Linux:

    -is aware of the device presence, and
    -has or has not identified the device
    regardless of whether the device is a flash memory (thumbdrive sort of thing), hard disk drive, CD or DVD reader or reader-writer:

    what are the various things going on inside Linux so that the state of these things can be consistently determined by the user?

    So is anyone able to explain in relatively simple terms what goes on from bootup differentiating between bus and device, especially including any commands that lead one to the information?

    Resource referral is welcome, but most of what I have googled up is in pretty deep technical language and I am looking for something more oriented toward newbies. TIA.

    Excerpted from lsusb -v
    Code:
    Bus 001 Device 001: ID 0000:0000
    Device Descriptor:
      bLength                18
      bDescriptorType         1
      bcdUSB               1.10
      bDeviceClass            9 Hub
      bDeviceSubClass         0 Unused
      bDeviceProtocol         0
      bMaxPacketSize0         8
      idVendor           0x0000
      idProduct          0x0000
      bcdDevice            2.06
      iManufacturer           3
      iProduct                2
      iSerial                 1
      bNumConfigurations      1
      Configuration Descriptor:
        bLength                 9
        bDescriptorType         2
        wTotalLength           25
        bNumInterfaces          1
        bConfigurationValue     1
        iConfiguration          0
        bmAttributes         0xe0
          Self Powered
          Remote Wakeup
        MaxPower                0mA
        Interface Descriptor:
          bLength                 9
          bDescriptorType         4
          bInterfaceNumber        0
          bAlternateSetting       0
          bNumEndpoints           1
          bInterfaceClass         9 Hub
          bInterfaceSubClass      0 Unused
          bInterfaceProtocol      0
          iInterface              0
          Endpoint Descriptor:
            bLength                 7
            bDescriptorType         5
            bEndpointAddress     0x81  EP 1 IN
            bmAttributes            3
              Transfer Type            Interrupt
              Synch Type               None
              Usage Type               Data
            wMaxPacketSize     0x0002  1x 2 bytes
          Self Powered
          Remote Wakeup
        MaxPower                0mA
        Interface Descriptor:
          bLength                 9
          bDescriptorType         4
          bInterfaceNumber        0
          bAlternateSetting       0
          bNumEndpoints           1
          bInterfaceClass         9 Hub
          bInterfaceSubClass      0 Unused
          bInterfaceProtocol      0
          iInterface              0
          Endpoint Descriptor:
            bLength                 7
            bDescriptorType         5
            bEndpointAddress     0x81  EP 1 IN
            bmAttributes            3
              Transfer Type            Interrupt
              Synch Type               None
              Usage Type               Data
            wMaxPacketSize     0x0002  1x 2 bytes
            bInterval             255

  2. #2
    Join Date
    Jan 2004
    Location
    boston, mass USA
    Posts
    1,880
    quickly, dmesg will show you anything new going on when you plug in a usb device.

    Mostly, they show up as /dev/sd? since linux see's usb as scsi.

    hope that helps
    m1ke_l
    Lenovo x120e (gave my wife the Asus 1015N)http://justlinux.com/forum/showthrea...hreadid=153955
    Fedora 16 (but I haven't settled yet)
    8gigs of RAM (in a NETBOOK!!)
    Boston, MA USA/Wondering

    My dad's website (he'll love the traffic) http://www.cafephotos.net/

  3. #3
    Join Date
    Jan 2004
    Location
    Milwaukee
    Posts
    313
    There are 2 issues here:
    1) as happybuny is asking, can you manually detect/mount a usb device;
    2) if 1), why doesn't the system do it automatically?

    The subsystem which automatically mounts your USB devices is the Hardware Abstraction Layer (HAL), so you might try googling on "ubuntu hald usb" to see what discussion you find.
    "Well, I've been to one world fair, a picnic, and a rodeo, and that's the stupidest thing I ever heard come over a set of earphones."

  4. #4
    Join Date
    Feb 2004
    Location
    Singapore
    Posts
    2,171
    The thing is, some distros have automatic facilities for usb built in, and some do not. In your case, ubuntu doesn't, and thus will sit there and do nothing when it knows a new usb device.

    Its actually about choice. If you want the functionality, you can easily install it if your system doesn't already have it. If you don't want the functionality, you can remove it too. I, for one, hate the autorun feature of windows. And the SONY CD's DRM scheme also attacks it, showing how bad automation can be if it is wrongly implemented (don't worry, linux has it well-thought out)
    Come under the reign of the Idiot King...
    Come to me ... I love linux!

    Registered Linux user: Idiot King #350544

  5. #5
    Join Date
    Mar 2003
    Posts
    287

    Triggering software events

    Hello here are a couple of articles on the matter you might find verry interesting.


    http://applications.linux.com/articl.../07/26/2129232

    and

    http://gentoo-wiki.com/HOWTO_ivman
    Live free or die ... LINUX

  6. #6
    Join Date
    Nov 2006
    Posts
    49

    USB devices

    Apology for absence, but was called away to deal with an emergency. Thanks most kindly for the several posts which will give me lots of reading, and also motivate me to get up to speed on dmesg. Very much a newbie here, so only understand a bit of what has been posted.

    Happybunny, my /dev directory does not have an /sd directory or a file by that name. There is a /bus directory which contains a /usb folder, but if I understand this, the information is about usb buses not devices and there is nothing which helps me find any USB devices.

    Dr Chuck, I am totally unable to find or activate any USB device that does not self-activate. That is why I am trying to understand the process and so will know how to do this regardless of the type of USB device employed.

    XiaoKJ, I am very encouraged by:
    Code:
    you can easily install it if your system doesn't already have it.
    . If you could kindly lay out the steps to do this, I would be very much obliged.

    Will get on with my googling and reading and will be most appreciative of any explanations anyone might offer.

  7. #7
    Join Date
    Nov 2006
    Posts
    49
    To further refine my question, I assume that all distros operate the same way, but please advise if not. I am using Ubuntu 6.06.

    First is the layer of hardware that the USB ports are connected to. Does Linux always use the same directory to place files that "connect" the motherboard to these ports? If so, which directory? If possible to say, what files? (is it correct to call this "bus" info?)

    Then when a USB device is plugged in, Linux must record the event. Where? In what files?

    Assuming that it recognizes the device, Linux must make a file or record in a file the details of the device. Where and how does one see it?

    Many thanks.

  8. #8
    Join Date
    Jun 2004
    Location
    Newcastle upon Tyne
    Posts
    2,956
    Seems a lot of questions for something simple.

    I always type in the terminal
    Code:
    fdisk -l
    (-l is nagative small "L".)

    If a USB device is hooked it will be reported as sda or sdb or whatever sdx after the Sata disks. That means if you have no Sata the 1st USB device will be named sda and the 2nd sdb. Having two Sata already installed can force the same USB devices to take up sdc and sdd.

    Some older distros name the same USB devices as hde, hdf and so on after the standard IDE disks hda to hdd. However no Linux will give the IDE disk names to USB devices as hda to hdd are named specifically to the electrical connection of the IDE cables.

    You can plug and unplug any USB device and the "fdisk -l" will show up their appearance and disappearance. Modern Linux kernels are pretty good in reporting USB devices, be it a memory stick or an external hard disk.

    I haven't paid much attention to inserting and removing several USB devices but I believe there is a protocol on it. For example if you have sda and sdb working the removal sda will not upset sdb. However if you pull sdb out too and put it back alone without the first USB device then it may get recognised as sda as it is the first one to the kernel.
    Linux user started Jun 2004 - No. 361921
    Using a Linux live CD to clone XP
    To install Linux and keep Windows MBR untouched
    Adding extra Linux & Doing it in a lazy way
    A Grub menu booting 100+ systems & A "Howto" to install and boot 145 systems
    Just cloning tips Just booting tips A collection of booting tips

    Judge asked Linux "You are being charged murdering Windoze by stabbing its heart with a weapon, what was it?" Replied Linux "A Live CD"

  9. #9
    Join Date
    Nov 2006
    Posts
    49
    Saikee, Thanks for the very informative post. I have been hoping to learn that it is indeed simple, and just standing back from the computer, it does not seem that it should be difficult.

    But:

    Code:
    fdisk -l
    yields:

    Disk /dev/hda: 81.9 GB, 81964302336 bytes
    255 heads, 63 sectors/track, 9964 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes

    Device Boot Start End Blocks Id System
    /dev/hda1 1028 3067 16386300 f W95 Ext'd (LBA)
    /dev/hda3 * 8 1027 8193150 c W95 FAT32 (LBA)
    /dev/hda5 2048 3067 8193118+ b W95 FAT32
    /dev/hda6 1028 2047 8193087 83 Linux

    Partition table entries are not in disk order
    Not sure what
    Partition table entries are not in disk order
    means, and hope it isn't a warning of some sort, nonetheless there is a USB printer and a USB scanner both attached to this computer and both are working. I don't see them in the fdisk output. (BTW, there are no SATA drives on this computer) Am I misunderstanding something?

  10. #10
    Join Date
    Feb 2004
    Location
    Singapore
    Posts
    2,171
    I think there is automount or something. The others should have a better idea what is the best option for ubuntu right now (because I don't use the auto mounting feature, and I don't use ubuntu)

    apt-get install automount

    should do the trick. Or else, someone else please help.

    PS: if nobody wants to help, it may be because the people here would like you to learn more about linux first, before doing such a thing.
    Come under the reign of the Idiot King...
    Come to me ... I love linux!

    Registered Linux user: Idiot King #350544

  11. #11
    Join Date
    Jun 2004
    Location
    Newcastle upon Tyne
    Posts
    2,956
    Odyssey,

    Your Linux did not report the USB device and so it isn't there. By USB devices I mean disk storage media like memory sticks, external hard disks etc.

    USB printer and scanner do not store files and that cannot be placed in the Linux filing system. Thus they will not be reported by fdisk.

    Regard the warning of " Partition table entries are not in disk order" it is quite harmless but it does highlight the erratic way you have arranged the partitions.

    Your partition table tells me you used the beginning of the disk with unit 8 to 1027 as hda3.

    Your hda1 is an extended partition holding hda5 from 2048 to 3067 and hda6 from 1028 to 2047th unit.

    This tells me that you must have hda1 and hda2 created between unit 1 to 7 and then had them deleted with only hda3 left.

    When you started to have the first logical partition an extended partition must be set up and since there is no hda1 or hda2 Linux then select the first available reserved hda1 to hold the information. Linux must use one of the 4 available primary partition to turn it into an extended partition and the avilable choices are hda1, ha2 and hda4. Guess what you you choose if you are an operating system.

    The fact that you have hda5 at the rear end of hda6 would support my belief that you have both partition hda5 & hda6 in the correct consecutive order before but you decided to delete hda5. This forced Linux to shift the hda6 to the hda5 position and the space left behind became dead. At a later date you re-created hda6 in the dead empty space but Linux cannot shift the partitions any more because the information forms a continuous chain (i.e. no dead space). It can cause confusion if you try to count the units but discover the untidy disk order.
    Linux user started Jun 2004 - No. 361921
    Using a Linux live CD to clone XP
    To install Linux and keep Windows MBR untouched
    Adding extra Linux & Doing it in a lazy way
    A Grub menu booting 100+ systems & A "Howto" to install and boot 145 systems
    Just cloning tips Just booting tips A collection of booting tips

    Judge asked Linux "You are being charged murdering Windoze by stabbing its heart with a weapon, what was it?" Replied Linux "A Live CD"

  12. #12
    Join Date
    Apr 2001
    Location
    SF Bay Area, CA
    Posts
    14,950
    If you have a new-enough 2.6 version kernel, you can look around in /sys to find all your USB devices. However, it's kinda hard to figure out what each device is without knowing more about them.

    Specifically, /sys/bus/usb/devices/ has a bunch of symlinks to the "real" position under /sys that each of your USB devices is sitting. (This is probably under your PCI bus somewhere, because your USB adapter is plugged into a device on your PCI bus.) The "usbX" symlinks point to individual USB buses, I think.

    The "1-0:1-0"-style symlinks, OTOH, point to actual USB devices. Some of these are hubs, some are probably input devices, some are likely storage-class devices if you have a usb-storage device plugged in, and some are probably printers if you have one of those plugged in. The directory that each one of these points to will have a "driver" symlink in it -- this will point to the driver that's bound to that device. If it points at ....../drivers/hub, then you're looking at a hub. If it points to ....../drivers/usbhid, then it's an HID (input) device. Other symlink target names should make it relatively obvious what type of device you're looking at.

  13. #13
    Join Date
    Nov 2006
    Posts
    49
    Wow, what fantastic replies. These are very helpful.

    saikee, what you are seeing is the result of "Well, I have to get started somewhere" and plunging into a partitioning exercise that I did (do) not understand with the hope that something might materialize that would be the beginning of a learning process and an exodus away from Windoze. I recognize that I made a mess of it but, all credit to Linux/Ubuntu, it is coping. Next time will be better.

    I am incorporating your comments into my resources that hopefully will ultimately result in a rock solid, efficient system. I am getting a bit long in the tooth, but throughout my lifetime, my continuing greatest joy has been in learning (slow as this process has become), and Linux/Ubuntu are extending this gratifying activity. I would also welcome any referral to any resources that you know that will help me improve my partitioning next time, and of course would be delighted to receive any further guidance you might wish to impart.

    XiaoKJ, absent further input, will likely plunge into automount in the next few days and see what happens. I find that I don't increase my understanding significantly until I have to start solving problems, and automount sounds like an opportunity!

    I wanted to comment on all the great posts, but got stuck into exploring /sys/bus/.....various directories and see that there is a lot there to try to decipher and so may be awhile before I respond, likely with questions, to bwkaz. Would be grateful for any URL'S or other resources that will give me some insights into what all of these directories and subdirectories and properties mean.

    Thanks again.

  14. #14
    Join Date
    Dec 2000
    Location
    Glasgow, Scotland
    Posts
    4,361
    I'm quite surprised that what you're plugging in isn't recognised by Ubuntu - I've had the reverse experience: everything I've plugged in has been recognised.

    lsusb should give relatively helpful info (the -v makes it more verbose, which is not always good). For the new user, usbview (if installed) provides a nice graphical frontend. Also, if you go to System -> Administration -> Device Manager there is also some stuff in there for USB.

    dmesg should provide useful information when the device is plugged in, which may help ascertain what the problem is.
    mrBen "Carpe Aptenodytes"

    Linux User #216794

    My blog page

    3rd year running - get yourself to LugRadio Live 7th-8th July 2007, Wolverhampton, UK. The premier FLOSS community event.

  15. #15
    Join Date
    Feb 2004
    Location
    Singapore
    Posts
    2,171
    Can you output the contents of lsmod? Since usb devices are not recognised, I suspect that the usb devices' modules are not loaded for some unknown reason.

    If, in the list given, usb-storage and so on, are not loaded, I will not be surpised to hear that usb devices are not recognised.

    Finally, if you are really going to try out automount, please do a google search on it and learn about it before you commit yourself to it. IIRC, something in that realm was changed recently. I myself do not wish that you install something old and not upgradable and have a bad time as a result.
    Come under the reign of the Idiot King...
    Come to me ... I love linux!

    Registered Linux user: Idiot King #350544

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •