Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

A drive is beginning to fail and I only know the device by its /dev/sdb device file designation. What are the ways that I can use to correlate that device file to an actual hardware device to know which drive to physically replace?

Bonus: What if I don't have /dev/disk/ and its sub directories on this installation? (Which, sadly, I don't)

share|improve this question
    
This is a good question! I hope you get many useful answers so I can refer to this in the future. –  Handyman5 Jun 8 '12 at 21:14
    
No RAID controller? –  ewwhite Jun 8 '12 at 21:44
    
@ewwhite Not for the purposes of this question, no. =) –  Wesley Jun 8 '12 at 21:51
    
btw. if you don't have the /dev/disk/ directory you probably don't have udev. –  Ulrich Dangel Jun 9 '12 at 3:32
    
@UlrichDangel Very observant because... I don't have udev. =( –  Wesley Jun 9 '12 at 3:43

6 Answers 6

up vote 13 down vote accepted

You can look in /sys/block:

-bash-3.2$ ls -ld /sys/block/sd*/device
lrwxrwxrwx 1 root root 0 Jun  8 21:09 /sys/block/sda/device -> ../../devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0
lrwxrwxrwx 1 root root 0 Jun  8 21:10 /sys/block/sdb/device -> ../../devices/pci0000:00/0000:00:1f.2/host1/target1:0:0/1:0:0:0
lrwxrwxrwx 1 root root 0 Jun  8 21:10 /sys/block/sdc/device -> ../../devices/pci0000:00/0000:00:1f.2/host2/target2:0:0/2:0:0:0
lrwxrwxrwx 1 root root 0 Jun  8 21:10 /sys/block/sdd/device -> ../../devices/pci0000:00/0000:00:1f.2/host3/target3:0:0/3:0:0:0

Or if you don't have /sys, you can look at /proc/scsi/scsi:

-bash-3.2$ cat /proc/scsi/scsi 
Attached devices:
Host: scsi0 Channel: 00 Id: 00 Lun: 00
  Vendor: ATA      Model: ST31000340AS     Rev: SD1A
  Type:   Direct-Access                    ANSI SCSI revision: 05
Host: scsi1 Channel: 00 Id: 00 Lun: 00
  Vendor: ATA      Model: ST31000340AS     Rev: SD1A
  Type:   Direct-Access                    ANSI SCSI revision: 05
Host: scsi2 Channel: 00 Id: 00 Lun: 00
  Vendor: ATA      Model: ST31000340AS     Rev: SD1A
  Type:   Direct-Access                    ANSI SCSI revision: 05
Host: scsi3 Channel: 00 Id: 00 Lun: 00
  Vendor: ATA      Model: ST31000340AS     Rev: SD1A
  Type:   Direct-Access                    ANSI SCSI revision: 05
Host: scsi4 Channel: 00 Id: 00 Lun: 00
  Vendor: PepperC  Model: Virtual Disc 1   Rev: 0.01
  Type:   CD-ROM                           ANSI SCSI revision: 03
share|improve this answer
    
Awesome, I have /sys/ (as well as /proc/) Lots of great info there. Still consuming it. –  Wesley Jun 8 '12 at 21:24
    
Also, take a look at /dev/disk/by-path (assuming your udev supports it). Of course, OPs doesn't, so... –  derobert Jun 8 '12 at 21:39

Assuming this is Linux, most obvious thing is to check dmesg for where the kernel first initializes the device. It logs the drive model.

share|improve this answer
    
Check unix.stackexchange.com/questions/39886/… for more details. –  jippie Jun 8 '12 at 21:16
    
Yes, it's Linux. Specifically Debian 4. I checked dmesg, but didn't see any mention of a drive model, oddly. Perhaps I'm misreading it. –  Wesley Jun 8 '12 at 21:24

If you can see the LED on the drive, or listen to the disk noise, you can run

sudo cat /dev/sdb >/dev/null

and see which drive suddenly becomes continuously active. Or, if you're going by noise,

sudo find /mount/point >/dev/null

which will make the heads move more (it may be better not to do it on the failing disk, and instead use a process of elimination with the other disks).

share|improve this answer
2  
I had considered how to get the lights to go blinky-blinky, so this is an answer to that curiosity of mine. =) –  Wesley Jun 8 '12 at 21:20
1  
Some drives have an extra LED for this, but they're usually only found in enterprise grade drives (read bizarrely expensive at relatively low capacity). Don't know how to work those LED's, but the dd trick usually works well enough. –  jippie Jun 8 '12 at 21:24
    
@WesleyDavid Even if there are no LEDs, listening to the noise can be a last recourse. There's no need to use dd here (nor in most circumstances), cat or any other program that reads from a file will do. –  Gilles Jun 9 '12 at 22:55
hdparm -i /dev/sdb

That should give you the model and serial number of the drive.

share|improve this answer
    
This would work for most situations, I believe. However, for some reason the controller in this server is sketchy. Performing that command earns me this: HDIO_GET_IDENTITY failed: Invalid argument –  Wesley Jun 8 '12 at 21:19
    
smartctl -i is worth trying, too. Works on SCSI drives, whereas hdparm often won't. –  derobert Jun 8 '12 at 21:41

As the inimitable Gilles mentioned in this answer of his, if your kernel uses udev you can use the udevadm command to interrogate a device:

udevadm info -n /dev/sda -a

(Sadly, in some cases [doubly sad is that it's true in this case for me] udev is not used and/or udevadm is not available.)

share|improve this answer

I have 4 methods. The first one is the easiest:

dmesg | egrep "sd[a-z]"

For the others, I'm not sure if they need /dev/disk except for this one:

ls -lF /dev/disk/by-uuid

The others:

blkid -o list -c /dev/null

And the obvious:

fdisk -l
share|improve this answer

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.