Gentoo Wiki


This article is still a Stub. You can help Gentoo-Wiki by expanding it.



Sometimes you plug in a usb peripheral or two, or three. And then you reboot. Then all the sudden, you have three devices occupying the scsi layer, and any of them could be the first, second, or third disk. How to tell which is which?

With fdisk

You can use fdisk! Fdisk will list each disk device, and will show partitions, blocks, filesystems, etc:

Disk /dev/sda: 127 MB, 127451136 bytes
4 heads, 61 sectors/track, 1020 cylinders
Units = cylinders of 244 * 512 = 124928 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/sda               1        1020      124409+   b  W95 FAT32

With dmesg

A common thing to do is using dmesg. Usually dmesg contains a lot of information and the output gets quite long. Therefore, you can use various methods to ease reading. Choose your favorite from the following:

With udev

Using udev, probably the easiest way is to query udevinfo the following way:

udevinfo -q env -n /dev/sdX

where you replace the X with the appropriate device node name. This does not need to be more than a, b etc. As far as I know, there is no direct way you can query udevinfo on a vendor/model name.
Now in my case, this returns something like

$ udevinfo -q env -n /dev/sda

If there is no info available, it returns

$ udevinfo -q env -n /dev/sda
no record for 'sda' in database

My suggestion for using this in a script is to do

udevinfo -q env -n /dev/sdX | grep ID_SERIAL

You can check there what device you are dealing with, giving you both Vendor and Model (you could do those separately, obviously). With the line grep returns, you can check the name and mount it on the right mountpoint. If grep returns nothing, apparently there wasn't any device at the node you were trying to query on.

With volume names

You can give your partitions a name to make them uniquely recognizable.

For a reiserfs partition, do:

reiserfstune -l <LABEL> <partition>

For ext2/2xt3, do:

tune2fs -L <LABEL> <partition>

You can then see the partition names with fdisk.

A nifty feature is to mount a partition according to its label. Given an ext3 partition called STORAGE, add the following entry to your /etc/fstab:


You will then be able to mount the partition as soon as its device node got created by udev, using only the mount point.


Retrieved from ""

Last modified: Mon, 08 Sep 2008 07:58:00 +0000 Hits: 15,422