Announcement

Collapse
No announcement yet.

usb device names (/dev/sdx)

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    usb device names (/dev/sdx)

    I'm not having a problem, I'm just hoping someone can enlighten me as to how the drive ids (paths?) are assigned to usb devices.
    And by extension, where to look to determine the particular path to a particular usb device.

    Here's the crux of my dilemma. I have an external drive that the majority of the time when I plug it in is assigned to /dev/sdb.
    I just plugged in a thumbdrive and assumed it would get /dev/sdc, however I couldn't mount it as such. I remembered once using /dev/sdg, so I tried that and it worked.

    It just made me curious as to how these names are assigned: Arbitrary? Or is there some method behind the madness?

    #2
    Re: usb device names (/dev/sdx)

    Originally posted by Zachf

    It just made me curious as to how these names are assigned: Arbitrary? Or is there some method behind the madness?
    For your purpose, I think the answer would be "According to no discernable pattern".

    Seriously, you need remember the original theory of the Universal Serial Bus -- a computer can have zero or any number of them, they can be used for all kinds of devices including, but not limited to, storage devices, and the "next plugged" device will be assigned the "next available" address. See the problem? Unlike your fixed internal disk drives, there is no way for the operating system to know what will be plugged into the USB bus next.

    So, your best bet is to plan to hotplug your external drive in, let it be automounted, and just use it that way. It should not matter what the /dev/sdxx number is.

    If for some reason it is very important for you to have it mounted in /etc/fstab to a fixed mount point in your filesystem, then you need to use "mount by-uuid"* and use its UUID number as it's identification, instead of an ever-changing /dev/sdxx number. You can find its UUID by issuing
    Code:
    sudo blkid
    and match the output of that with the output of
    Code:
    sudo fdisk -lu
    to make sure you have the right device and partition.


    * example from my /etc/fstab file:

    Code:
    UUID=1e908a65-7ddb-4a1f-9913-d5a82ddb3137   /mnt/MUSIC   ext4    auto,users,rw,exec,noatime

    Finally, don't forget -- if you set it up to be mounted in /etc/fstab, and then try to boot when it's not connected, you'll have problems booting. That's why i recommend you just hotplug it when the system is running.

    Comment


      #3
      Re: usb device names (/dev/sdx)

      While running Jaunty and Karmic I had to install "usbmount" to get the features I describe below, but with Lucid, even though usbmount is not installed, everything works well.

      Before I plug in any USB devices I have
      jerry@sonyvgnfw140e:~/$ vdir /dev/usb*
      crw-rw---- 1 root root 252, 0 2010-09-01 06:15 /dev/usbmon0
      crw-rw---- 1 root root 252, 1 2010-09-01 06:15 /dev/usbmon1
      crw-rw---- 1 root root 252, 2 2010-09-01 06:15 /dev/usbmon2
      crw-rw---- 1 root root 252, 3 2010-09-01 06:15 /dev/usbmon3
      crw-rw---- 1 root root 252, 4 2010-09-01 06:15 /dev/usbmon4
      crw-rw---- 1 root root 252, 5 2010-09-01 06:15 /dev/usbmon5
      crw-rw---- 1 root root 252, 6 2010-09-01 06:15 /dev/usbmon6
      crw-rw---- 1 root root 252, 7 2010-09-01 06:15 /dev/usbmon7
      crw-rw---- 1 root root 252, 8 2010-09-01 06:15 /dev/usbmon8

      and ...

      jerry@sonyvgnfw140e:~/$ vdir /dev/sd*
      brw-rw---- 1 root disk 8, 0 2010-09-01 06:15 /dev/sda
      brw-rw---- 1 root disk 8, 1 2010-09-01 06:15 /dev/sda1
      brw-rw---- 1 root disk 8, 2 2010-09-01 06:15 /dev/sda2
      brw-rw---- 1 root disk 8, 5 2010-09-01 06:15 /dev/sda5
      During the following actions the /dev/usb* listing never changes.

      The /dev/sda device is my HD, and sda1, sda2 and sda5 are its partitions:
      jerry@sonyvgnfw140e:~$ sudo fdisk -l

      Disk /dev/sda: 250.1 GB, 250059350016 bytes
      255 heads, 63 sectors/track, 30401 cylinders
      Units = cylinders of 16065 * 512 = 8225280 bytes
      Sector size (logical/physical): 512 bytes / 512 bytes
      I/O size (minimum/optimal): 512 bytes / 512 bytes
      Disk identifier: 0x557f2607

      Device Boot Start End Blocks Id System
      /dev/sda1 * 1 30037 241267712 83 Linux
      /dev/sda2 30037 30402 2928641 5 Extended
      /dev/sda5 30037 30402 2928640 82 Linux swap / Solaris
      I plugged in two USB sticks.
      jerry@sonyvgnfw140e:~/Downloads/factor/work$ vdir /dev/sd*
      brw-rw---- 1 root disk 8, 0 2010-09-01 06:15 /dev/sda
      brw-rw---- 1 root disk 8, 1 2010-09-01 06:15 /dev/sda1
      brw-rw---- 1 root disk 8, 2 2010-09-01 06:15 /dev/sda2
      brw-rw---- 1 root disk 8, 5 2010-09-01 06:15 /dev/sda5
      brw-rw---- 1 root disk 8, 16 2010-09-01 15:40 /dev/sdb
      brw-rw---- 1 root disk 8, 17 2010-09-01 15:40 /dev/sdb1
      brw-rw---- 1 root disk 8, 32 2010-09-01 15:44 /dev/sdc
      brw-rw---- 1 root disk 8, 33 2010-09-01 15:44 /dev/sdc1


      and ..

      jerry@sonyvgnfw140e:~/Downloads/factor/work$ sudo fdisk -l

      Disk /dev/sda: 250.1 GB, 250059350016 bytes <--- MY Hard Drive
      255 heads, 63 sectors/track, 30401 cylinders
      Units = cylinders of 16065 * 512 = 8225280 bytes
      Sector size (logical/physical): 512 bytes / 512 bytes
      I/O size (minimum/optimal): 512 bytes / 512 bytes
      Disk identifier: 0x557f2607

      Device Boot Start End Blocks Id System <--- and its partition list
      /dev/sda1 * 1 30037 241267712 83 Linux
      /dev/sda2 30037 30402 2928641 5 Extended
      /dev/sda5 30037 30402 2928640 82 Linux swap / Solaris

      Disk /dev/sdb: 8011 MB, 8011120640 bytes <-- first USB stick
      255 heads, 63 sectors/track, 973 cylinders
      Units = cylinders of 16065 * 512 = 8225280 bytes
      Sector size (logical/physical): 512 bytes / 512 bytes
      I/O size (minimum/optimal): 512 bytes / 512 bytes
      Disk identifier: 0x4b824fc2

      Device Boot Start End Blocks Id System <-- and its partition list
      /dev/sdb1 1 973 7815591 83 Linux

      Disk /dev/sdc: 8086 MB, 8086617600 bytes <-- second USB stick
      255 heads, 63 sectors/track, 983 cylinders
      Units = cylinders of 16065 * 512 = 8225280 bytes
      Sector size (logical/physical): 512 bytes / 512 bytes
      I/O size (minimum/optimal): 512 bytes / 512 bytes
      Disk identifier: 0x000c8bbb

      Device Boot Start End Blocks Id System
      /dev/sdc1 * 1 984 7897056 c W95 FAT32 (LBA) <-- its partition list
      Partition 1 has different physical/logical endings:
      phys=(982, 254, 63) logical=(983, 36, 12)
      When the removable device dialog pops up it lists the device using the root directory name.
      The first was listed as:
      EMPTY
      and the second as:
      LinuxEXT4USBstic

      When those names are clicked on the mounting options open. Selecting Dolphin they are mounted under the /media directory as:
      /media/EMPTY
      /media/LinuxEXT4USBstic

      with the privileges of the user.

      When you right mouse on the device in the Folder panel of Dolphin you have the "safely remove" option to select. Click it and when the Dolphin directory for that device goes blank you can pull it out. Otherwise, you can click on the devices option in the System Tray and click the right triangle next to the name of the device ("EMPTY" or what ever) and it will unmount.

      The sdb and sdc devices in /dev did not exist before I plugged in the two USB sticks and mounted them graphically. IF I had more USB ports and continued to plug in more devices successive letters of the alphabet will continue to be used (I believe the limit may be nine (0-8) ). When I use the "safely remove" option and pull the sticks out the /dev/sdb and /dev/sdc files are deleted.

      All it all, it's a beautiful and transparent system.




      "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
      – John F. Kennedy, February 26, 1962.

      Comment


        #4
        Re: usb device names (/dev/sdx)

        Originally posted by GreyGeek

        When you right mouse on the device in the Folder panel of Dolphin you have the "safely remove" option to select. Click it and when the Dolphin directory for that device goes blank you can pull it out.
        Right -- I forgot to mention that VERY important point. Thanks GG!

        For a filesystem on a USB storage device, it is VERY important that you use the "eject" or "safely remove" option prior to yanking the USB connector out. Especially if it is a journalling filesystem (ext3/4, NTFS, etc.) you can really screw it up in a data-losing way if you merely yank it out without giving it a chance to flush the cache first.

        Comment


          #5
          Re: usb device names (/dev/sdx)

          Excellent. Thanks for the thorough replies.

          I love this community

          Comment


            #6
            Re: usb device names (/dev/sdx)

            ... and articles such as
            https://help.ubuntu.com/community/UsingUUID
            may be helpful.
            An intellectual says a simple thing in a hard way. An artist says a hard thing in a simple way. Charles Bukowski

            Comment


              #7
              Re: usb device names (/dev/sdx)

              This topic brings up an interesting problem I have. I plug in my usb hard drive.

              When time comes to safely remove it, I right click and do that. Watching the lights, they flicker and then the devices go away from desktop shortly only to come back again a second time.

              I have to safely remove a second time to have the device "really" removed.

              I haven't investigated it that much - looking at dmesg, for example, but it always happens on at least one of my external usb hard drives.
              Boot Info Script

              Comment


                #8
                Re: usb device names (/dev/sdx)

                By chance, on that particular USB HD, does it have more than one partition?
                Windows no longer obstructs my view.
                Using Kubuntu Linux since March 23, 2007.
                "It is a capital mistake to theorize before one has data." - Sherlock Holmes

                Comment


                  #9
                  Re: usb device names (/dev/sdx)

                  USB sticks that have the Windows "security" features on them show up as two partitions and two possible mounts. If you mount the data partition and not the "security" partition then you won't (or at least I don't) get two mounts. My "EMPTY" had two mount points, but I didn't show the "security" mount. BTW, any info put into the data partition while running Windows is encrypted if you use the security feature in the "security" partition. Mounting it with Linux won't expose the data because it is encrypted.

                  Usually, I repartition and reformat USB sticks with EXT4 or FAT32. FAT32 allows you to plug the stick into boxes running Windows, but EXT4 doesn't. (I haven't checked to see if there is an executable for Windows that allows one to read EXT4 partitions like there is for EXT2 and 3 partitions.
                  "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
                  – John F. Kennedy, February 26, 1962.

                  Comment


                    #10
                    Re: usb device names (/dev/sdx)

                    My latest stick is 8gb so I have a bootable kubuntu in 4gb - so I can boot to it, install (wubi) from it, and it has space for a few file (about 2gb). Then the second partition is 4gb reiser for my linux boxes. Works like a champ. When I plug it in to a linux box, both partitions show up as mountable devices (obvously).

                    I was wondering in the OP's case if his USB drive firmware was attempting the reconnect, thus explaining the lights.

                    You might try watching the log file via dmesg and see if it's umounting/remounting or just flashing it's lights.

                    Next time it re-lights up after an unmount, open a terminal and type "mount" to see if it's reattached or just lighting up.

                    Please Read Me

                    Comment

                    Working...
                    X