Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How can I find which /dev/? device to mount my USB hard drive on Red Hat 3 Taroon?  I've been Googling a lot and checked log files and still no clue. I'm trying my last chance with you experts,

# /sbin/fdisk -l

gives nothing about the USB drive.

# lsusb -vv
Bus 004 Device 005: ID 059f:0951 LaCie, Ltd 
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x059f LaCie, Ltd
  idProduct          0x0951 
  bcdDevice            0.00
  iManufacturer          10 LaCie
  iProduct               11 LaCie Hard Drive USB
  iSerial                 5 9F908FFFFFFF
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           32
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          4
    bmAttributes         0xc0
      Self Powered
    MaxPower                2mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass         8 Mass Storage
      bInterfaceSubClass      6 SCSI
      bInterfaceProtocol     80 Bulk (Zip)
      iInterface              6 MSC Bulk-Only Transfer
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               none
        wMaxPacketSize        512
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               none
        wMaxPacketSize        512
        bInterval               0
  Language IDs: (length=4)
     0409 English(US)

and here is some more which might be interesting

# /var/log/message
May 23 18:17:13 mypc kernel: USB.c: USB disconnect on device 00:1d.7-5 address 4
May 23 18:18:00 mypc kernel: hub.c: new USB device 00:1d.7-5, assigned address 5
May 23 18:18:00 mypc kernel: USB.c: USB device 5 (vend/prod 0x59f/0x951) is not claimed by any active driver.
share|improve this question

migrated from stackoverflow.com May 23 '11 at 20:22

This question came from our site for professional and enthusiast programmers.

add comment

5 Answers 5

Thank you all for your answers

The usb-storage module was not loaded in the kernel

modprobe usb-storage
share|improve this answer
add comment

dmesg is the place to find that information.

For example here is the output from a 'dmesg | tail' after plugging in a USB pendrive into my box

verrall@granite:~$ dmesg | tail
[4296470.550538] sd 46:0:0:0: [sdg] Write Protect is off
[4296470.550538] sd 46:0:0:0: [sdg] Mode Sense: 00 00 00 00
[4296470.550538] sd 46:0:0:0: [sdg] Assuming drive cache: write through
[4296470.555971] sd 46:0:0:0: [sdg] 16058440 512-byte hardware sectors (8222 MB)
[4296470.555971] sd 46:0:0:0: [sdg] Write Protect is off
[4296470.555971] sd 46:0:0:0: [sdg] Mode Sense: 00 00 00 00
[4296470.555971] sd 46:0:0:0: [sdg] Assuming drive cache: write through
[4296470.555971] sdg: sdg1
[4296470.764472] sd 46:0:0:0: [sdg] Attached SCSI removable disk
[4296470.764509] sd 46:0:0:0: Attached scsi generic sg7 type 0

From here I can see that my device is /dev/sdg and that it has one partition on it /dev/sdg1. So to mount this to /mnt I would do,

# sudo mount /dev/sdg1 /mnt

share|improve this answer
add comment

If you know the label of the partition you want to mount (say, the volume called "LaCie"), you can do a

sudo findfs LABEL="LaCie"

it will print out the device name corresponding to that partition.

share|improve this answer
add comment

What I usually do, is run dmesg|tail, after unplugging and plugging in the usb device.

There probably is a better method, but this works fine enough for me. :-)

share|improve this answer
add comment

I did a lot of Googling and the best solution I could find was to use dmesg. However, this is not a satisfactory answer for scripting. I could parse the output of dmesg, but then someone innocently adjusting a log message would break my script.

I found an answer that works for a Debian distribution with a 2.6.32-5-amd64 kernel. It seems that the files involved are not very distribution dependent, but I have not verified this.

The secret is remembering that, as far as the Linux kernel is concerned, USB drives are also SCSI drives. The command 'ls -l /sys/bus/scsi/devices' will show the contents of the directory to be a set of symbolic links. You will find that all the USB drives will link to a path containing the string 'usb', while non-USB drives will not have the string in the symbolic link path.

There are three sets of directories in /sys/bus/scsi/devices, the ?:?:?:? directory, the host? directory and the target?:?:? directory. You will find that the appropriate /sys/bus/scsi/devices/?:?:?:?/block directory contains a directory named after the device file it uses.

Here is a Perl fragment that shows how to get a list of device files, one for each USB drive:

opendir(DIR,"/sys/bus/scsi/devices") or die "Cannot enumerate SCSI devices\n";

while(my $file=readdir(DIR)) {
    next if($file eq '.');
    next if($file eq '..');
    next if(!(-l "/sys/bus/scsi/devices/$file"));
    next if(!($file=~/\d*:\d*:\d*:\d*/));
    if(readlink("/sys/bus/scsi/devices/$file")=~/usb/) {
        opendir(INNER_DIR,"/sys/bus/scsi/devices/$file/block") or die "Cannnot open $file/block\n";
        while(my $inner_file=readdir(INNER_DIR)) {
            next if($inner_file eq '.');
            next if($inner_file eq '..');
            push @dev_files, "/dev/$inner_file";
        }
        closedir INNER_DIR;
    }
}
closedir DIR;
die "No USB devices found\n" unless(scalar @dev_files);

for my $line (@dev_files) {
    print "$line\n";
}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.