Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I want to know which hard disk drive corresponds to which device path. It's trivial to match the hard disk stats (brand, size) with the dev path, but I want more. I want to know which drive is which inside my case. What's a good way to go about getting this info?

  • I would prefer not to tear apart my server to remove all the drives, then add back one by one.
  • I am willing to preform reboots.
  • The drives are inconveniently scrunched together in the case. The label information is hidden.
  • I can open the case. Most disks are SATA, so theoretically hot swappable. So, Unplugging and tracing cables might help in answering.
share|improve this question
1  
I'm confused!?! –  Allan Feb 25 '11 at 12:23
1  
This question was asked already. The best option is for LED activity: askubuntu.com/questions/11088/… –  Kees Cook Mar 7 '11 at 21:39
    
@Kees Cook Hmm, my pre-searches didn't pick that up, thanks. However, I'm especially happy with the cli answers I got in addition to the palimpsest utility. Also, my disks aren't in a RAID, and I have no LED displays. –  djeikyb Mar 7 '11 at 23:45
1  
@djeikyb Would you consider changing your accepted answer to the GUI one? That is probably the one most useful to new users who see this question. Thanks. –  Jacob Johan Edwards Sep 29 '12 at 13:35
add comment

10 Answers

up vote 13 down vote accepted

hdparm -i /dev/sdX gives you the serial number, which is the simplest way I know of to tell apart hard disks of the same brand and size.

The serial number is normally printed on a label on the disk, so although you need to open the case to find it, there's no need disassemble the computer.

Example:

$ sudo hdparm -i /dev/sdb | grep -i serial
 Model=SAMSUNG HD253GJ, FwRev=1AJ10001, SerialNo=S24JJ90Z505435

If you want more info lshw -c storage -c disk gives the most readable output. It's pretty much the same data as Disk Utility, just in command line format.

Here is an annotated example from the most complex setup I have access to, with four disk controllers, seven hard disks, a DVD ROM and a USB disk.

The output has been cut down to size to focus on the interesting parts:

[server ~]$ sudo lshw -c storage -c disk
  *-storage   
  # a 2-port PCI-E SATA controller
       description: SATA controller
       product: 88SE9123 PCIe SATA 6.0 Gb/s controller
       vendor: Marvell Technology Group Ltd.
     *-disk
          description: ATA Disk
          product: WDC WD15EADS-00P
          vendor: Western Digital
  # 'physical id' corresponds to port number, first port is 0
          physical id: 0  
          logical name: /dev/sdg
          serial: WD-WMAVU0849124
          size: 1397GiB (1500GB)
     *-cdrom
          description: DVD reader
          product: BD-ROM BR-5100S
          vendor: Optiarc
          physical id: 1
          logical name: /dev/cdrom1
          logical name: /dev/dvd1
          logical name: /dev/scd0
          serial: [Optiarc BD-ROM BR-5100S 1.02 May20 ,2008
  *-storage
  # mobo controller for eSATA ports. Not used.
       description: SATA controller
       product: JMB362/JMB363 Serial ATA Controller
       vendor: JMicron Technology Corp.
  *-ide
  # mobo controller for IDE. Not used.
       description: IDE interface
       product: JMB362/JMB363 Serial ATA Controller
       vendor: JMicron Technology Corp.
  *-storage
  # the primary SATA controller, six ports
       description: SATA controller
       product: 82801JI (ICH10 Family) SATA AHCI Controller
       vendor: Intel Corporation
  # 'disk:0' means port 0, same as physical id
     *-disk:0
          description: ATA Disk
          product: WDC WD1600BEVS-0
          vendor: Western Digital
          physical id: 0
          logical name: /dev/sda
          serial: WD-WXEY08T58317
          size: 149GiB (160GB)
     *-disk:1
          description: ATA Disk
          product: ST32000542AS
          vendor: Seagate
          physical id: 1
          logical name: /dev/sdb
          serial: 5XW1RTDS
          size: 1863GiB (2TB)
     *-disk:2
          description: ATA Disk
          product: ST32000542AS
          vendor: Seagate
          physical id: 2
          logical name: /dev/sdc
          serial: 5XW23W0W
          size: 1863GiB (2TB)
     [...]
  *-scsi
  # the USB disk, as evidenced by the bus info 
       physical id: 1
       bus info: usb@1:1
       capabilities: emulated scsi-host
     *-disk
          description: SCSI Disk
          product: 10EAVS External
          vendor: WD
          physical id: 0.0.0
          logical name: /dev/sdh
          serial: WD-WCAU46029507
          size: 931GiB (1TB)

I think the Disk Utility is faster to read; the command line version has the advantage of being usable over ssh and in scripts.

And I still think the serial number is the most reliable solution :)

The "Physical ID" of each drive corresponds to where it is connected to the motherboard. and starts with 0. so a physical ID of 2 would mean that the drive is attached to the 3rd sata port of your mobo or other applicable device.

share|improve this answer
    
Interesting. The serial/label is nice to have, but in my scenario the disks are crammed in a holder that blocks the sticker from view. The best I can do is trace the cables. I didn't see anything in hdparm -i immediately useful, but I'll have to read through the man page to see if I can't get more info out of it. –  djeikyb Feb 25 '11 at 11:54
    
Haha, the serial is indeed most reliable, but this gives the useful map of linux device recognition -> physical hookups...through a command line interface. Thanks! –  djeikyb Mar 7 '11 at 23:37
add comment

Disk Utility

This is a GUI application that will give you information about the model, size, serial number and device path of your drives. It is installed by default on Ubuntu Desktop. You can press the Ubuntu Dash button and search "disk utility" to find it, or run it in the terminal with palimpsest.

Disk Utility

share|improve this answer
3  
and you only need to use one hand and finger thats what I call energy conservation "save the planet use disk utility" –  Allan Feb 25 '11 at 10:06
1  
I think this will be the answer, with "Location: Port X of SATA Host Adapter" being the killer feature. I'd love to see some cli answers too though. Octavian & faustus have interesting solutions along those lines –  djeikyb Feb 25 '11 at 11:19
add comment

Open the case and listen to the drives with a rolled up copy of "The Linux Journal". Then run a dd on each drive in turn to generate some disk noise.

share|improve this answer
2  
Stethoscope ftw –  Jeremy Mar 6 '11 at 5:28
1  
Love this answer. I prefer the technical output of palimpsest and lshw, but this is a close third. –  djeikyb Mar 7 '11 at 23:40
add comment

I recommend hwinfo --disk.

This will list all relevant information for your hard disks. If you need more information about your partitions you can use hwinfo --partition.

You can combine both of the above with the --short option to get a shorter representation.

share|improve this answer
    
This looks most promising, especially the SysFS and Device Files lines, but I'm not sure how to translate them into english. –  djeikyb Feb 25 '11 at 11:56
add comment

You can get that information from /sys (or /dev, for that matter):

anthony@Zia:~$ ls -l /sys/block/ | grep sd.
lrwxrwxrwx 1 root root 0 Feb 25 13:30 sda -> ../devices/pci0000:00/0000:00:1f.2/host2/target2:0:0/2:0:0:0/block/sda
lrwxrwxrwx 1 root root 0 Feb 25 13:30 sdb -> ../devices/pci0000:00/0000:00:1f.2/host3/target3:0:0/3:0:0:0/block/sdb
lrwxrwxrwx 1 root root 0 Feb 25 13:30 sdc -> ../devices/pci0000:00/0000:00:1f.2/host4/target4:0:0/4:0:0:0/block/sdc
lrwxrwxrwx 1 root root 0 Feb 25 13:30 sdd -> ../devices/pci0000:00/0000:00:1f.2/host5/target5:0:0/5:0:0:0/block/sdd

So, you can see my four disks are on ports (hosts/targets) 2 through 5.

You can also do the ls -l on /dev/disk/by-path and see it there.

share|improve this answer
    
+1 for accessing the basic info from /sys and /dev. I still like the aggregate info from the accepted solutions better, but knowing how to get and read the base info is invaluable. This is a missing part of the larger answer that @j-g-faustus and @Allan gave –  djeikyb Mar 11 '11 at 1:12
add comment
  • cat /proc/partitions show detected partitions/disk by the kernel, you can figure out by the size

enter image description here

  • smartctl -i /dev/sda

enter image description here

share|improve this answer
add comment

Hardinfo is a GUI which will allow you to gather your system Information, which may include, but not limited to, the physically connected Storage Devices and the File Systems, as shown in the next screenshots:

enter image description here

enter image description here

Hardinfo website: http://hardinfo.berlios.de/HomePage

share|improve this answer
add comment

Quickest and Easiest Way

1. Open Gnome-Terminal

2. Enter sudo blkid

3. Enter Password

4. It will tell you which drive is which in an easy to read format

share|improve this answer
add comment

If you want a way without being able to see the labels, which as far as I know none of the other responses do. I would unmount all of the drives (If possible, you may have to boot from a live cd to do this). All the drives should now spin down. You can then progressively mount each one and listen or feel which one spins up. This way you only need the lid off your case but you don't need to see tha labels which is nice if they're all tangled up.

Simples

share|improve this answer
add comment

If you just want to see which partitions are mounted in what directories, then you can simply type mount.

/dev/sda1 on / type ext4 (rw,errors=remount-ro,commit=0)

For a GUI method, the easiest is to open System Monitor, which is installed by default. Look at the file system page:

enter image description here

share|improve this answer
    
Quite so. Unfortunately for your answer, the question is not relating partitions to directories, but software labels to physical disks. Ie, I was too stupid when I built the computer to write the UUID on the hd where it is easily visible, and now I'm too lazy to take the computer apart and check each drive one by one. –  djeikyb Aug 26 '11 at 1:01
1  
oh, ok. Then you should edit your question, I think. Perhaps you should have a look at /dev/disk/by-* –  Jo-Erlend Schinstad Aug 26 '11 at 5:07
    
Can you suggest how my question would be clearer? I'm open to improvements. Also, I'll upvote your answer if you elaborate how /dev/disk/by-* helps me. –  djeikyb Aug 26 '11 at 6:43
add comment

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.