8

I have an Ubuntu installation which has a lot of hard drives. Two of these drives have hiccups and SMART is reporting errors. However, I cannot figure out how to determine which drive is ata1.00 and which is ata12.00. Is it possible to retrieve their serial numbers, as this would be easiest way to find the correct drives?

2

6 Answers 6

6

ls -l /sys/class/ata_port/ should show the link to PCI id. Then ls -l /dev/disk/by-path/ would tell you what /dev/* that that is assigned to.

3

Look at ls -l /dev/disk/by-path and find the sd* device that corresponds. Then look at ls -l /dev/disk/by-id for the model and serial number that corresponds to that sd* device.

You may find this helpful:

sudo lshw -class disk -short

(or try it without the -short but pipe it into less).

5
  • Ok, using lshw, I get: /0/100/1c.1/0/0 /dev/sda disk 1TB WDC WD10EADS-00M. Is there any information about how mapping between /0/100/1c.1/0/0 with ata1.00?
    – mamruoc
    Commented Mar 2, 2011 at 11:44
  • @user70520: What do the ls ... /dev/disk commands I posted tell you? Commented Mar 2, 2011 at 11:57
  • @user70520: What is it that's reporting the drive as "ata1.00"? Try this to get a list of serial numbers (and other information) about all your drives: for d in /dev/sd?; do sudo smartctl -i $d; done | less. Commented Mar 2, 2011 at 12:06
  • I get SMART error in dmesg, thus I have to identify corect drives to replace: [2293721.950045] ata12.00: status: { DRDY } [2293721.950051] ata12: hard resetting link
    – mamruoc
    Commented Mar 2, 2011 at 12:36
  • I need to figure out which drive ata12.00 is. If I get either /dev/sdX or serial, I can figure out which drive I need to replace.
    – mamruoc
    Commented Mar 2, 2011 at 12:37
2

You can look at the output of ll /sys/block which shall give you something similar to

total 0
drwxr-xr-x  2 root root 0 Aug  8 09:00 ./
dr-xr-xr-x 13 root root 0 Jul  9 14:55 ../
lrwxrwxrwx  1 root root 0 Aug  8 09:00 dm-0 -> ../devices/virtual/block/dm-0/
lrwxrwxrwx  1 root root 0 Aug  8 09:00 loop0 -> ../devices/virtual/block/loop0/
lrwxrwxrwx  1 root root 0 Aug  8 09:00 loop1 -> ../devices/virtual/block/loop1/
lrwxrwxrwx  1 root root 0 Aug  8 09:00 loop2 -> ../devices/virtual/block/loop2/
lrwxrwxrwx  1 root root 0 Aug  8 09:00 loop3 -> ../devices/virtual/block/loop3/
lrwxrwxrwx  1 root root 0 Aug  8 09:00 loop4 -> ../devices/virtual/block/loop4/
lrwxrwxrwx  1 root root 0 Aug  8 09:00 loop5 -> ../devices/virtual/block/loop5/
lrwxrwxrwx  1 root root 0 Aug  8 09:00 loop6 -> ../devices/virtual/block/loop6/
lrwxrwxrwx  1 root root 0 Aug  8 09:00 loop7 -> ../devices/virtual/block/loop7/
lrwxrwxrwx  1 root root 0 Aug  8 09:00 md0 -> ../devices/virtual/block/md0/
lrwxrwxrwx  1 root root 0 Aug  8 09:00 nvme0n1 -> ../devices/pci0000:00/0000:00:01.1/0000:01:00.0/nvme/nvme0/nvme0n1/
lrwxrwxrwx  1 root root 0 Aug  8 09:00 nvme1n1 -> ../devices/pci0000:00/0000:00:01.2/0000:20:00.0/0000:21:01.0/0000:23:00.0/nvme/nvme1/nvme1n1/
lrwxrwxrwx  1 root root 0 Aug  8 09:00 nvme2n1 -> ../devices/pci0000:00/0000:00:03.1/0000:2d:00.0/nvme/nvme2/nvme2n1/
lrwxrwxrwx  1 root root 0 Aug  8 09:00 sda -> ../devices/pci0000:00/0000:00:01.2/0000:20:00.0/0000:21:0a.0/0000:2c:00.0/ata6/host5/target5:0:0/5:0:0:0/block/sda/
lrwxrwxrwx  1 root root 0 Aug  8 09:00 sdb -> ../devices/pci0000:00/0000:00:01.2/0000:20:00.0/0000:21:09.0/0000:2b:00.0/ata1/host0/target0:0:0/0:0:0:0/block/sdb/
2
lshw -C disk

will get you drives, their product ids, and mount points.

*-disk:0                
       description: ATA Disk
       product: XXXX
       vendor: Seagate
       physical id: 0
       bus info: scsi@0:0.0.0
       logical name: /dev/sda
       version: JC4B
       serial: XXXYYY
       size: 931GiB (1TB)
       capabilities: partitioned partitioned:dos
       configuration: ansiversion=5 signature=0006ded4

You can then find their most recent mount info in /var/log/syslog, with something like (e.g. looking for disk /dev/sda)

cat /var/log/syslog | grep 'sda' -A 5 -B 5

for other info, you can also try

blkid

or

mount
1

If you don't know the device name but know the bus number of an IDE harddrive, and want to find out the serial number, you can do:

cat /sys/bus/ide/devices/0.0/serial

Where "0.0" is the bus number.

2
  • I do not have ide, but sata which seems to map to scsi on Ubuntu Lucid: root@na:/sys/bus/scsi/devices# ls 0:0:0:0 11:0:0:0 15:0:0:0 6:0:0:0 host0 host10 host12 host14 host16 host2 host4 host6 host8 target0:0:0 target11:0:0 target15:0:0 target6:0:0 10:0:0:0 14:0:0:0 3:0:0:0 7:0:0:0 host1 host11 host13 host15 host17 host3 host5 host7 host9 target10:0:0 target14:0:0 target3:0:0 target7:0:0. I am do not seem to be able to find the missing link.
    – mamruoc
    Commented Mar 2, 2011 at 8:57
  • I suspect you're missing 'lsscsi' which will output something like : [0:0:0:0] disk ATA ST3500630AS 3.AA /dev/sda [1:0:0:0] disk ATA WDC WD5000AAKS-0 05.0 /dev/sdb [6:0:0:0] cd/dvd TSSTcorp CDDVDW SH-S202H SB00 /dev/sr0 Where ATA.1 is /dev/sdb and ATA.0 would be /dev/sda. Commented Oct 1, 2013 at 12:13
0

You want hdparm -i /dev/whatever.

4
  • root@na# hdparm -i /dev/sdb /dev/sdb: Model=WDC, FwRev=80.00A80, SerialNo=WD-WCAVY1924737 Config={ HardSect NotMFM HdSw>15uSec SpinMotCtl Fixed DTR>5Mbs FmtGapReq } RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=50 BuffType=unknown, BuffSize=0kB, MaxMultSect=16, MultSect=16 CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=3907029168 IORDY=on/off, tPIO={min:120,w/IORDY:120}, tDMA={min:120,rec:120} [snip] Drive conforms to: Unspecified: ATA/ATAPI-1,2,3,4,5,6,7 I am still not able to see how I can determine which drive (sdX) corresponds to ata1.00
    – mamruoc
    Commented Mar 2, 2011 at 7:44
  • @user70520: You wanted the serial number; there it is: “SerialNo=WD-WCAVY1924737”.
    – Teddy
    Commented Mar 2, 2011 at 7:54
  • I wanted the serial number, yes. but I want the serail number of harddrive which corresponds to ata1.00. That is my main problem, pfinding the link between ata1.00 and /dev/sdX
    – mamruoc
    Commented Mar 2, 2011 at 7:59
  • @user70520: Oh, you don't have the device name? Right - see separate answer.
    – Teddy
    Commented Mar 2, 2011 at 8:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .