November 2014
M T W T F S S
« Mar    
 12
3456789
10111213141516
17181920212223
24252627282930
135

Refs

Categories

Archives

profile for slm on Stack Exchange, a network of free, community-driven Q&A sites

[one-liner]: Determining a Hard Drive’s Manufaturer Under Fedora 10 & CentOS 5

Background

I recently saw a post over on Linux Journal that discussed how to glean information about a system’s hard drive, such as its serial number, without having to actually open up the case and physically check it. So I thought I’d take the opportunity to write up a blog post with the specifics of how to do this under Fedora & CentOS, just so I’d have this info handy for future use.

BTW, I was able to accomplish this task several different ways, so this post will cover all the different ways that I could get this info.

Command #1: lshw

This is probably the best tool for getting at a system’s internals. First make sure it’s installed.

1
yum install lshw

For our example you would run the command lshw -class disk:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
% lshw -class disk
  *-disk                  
       description: ATA Disk
       product: HTS726060M9AT00
       vendor: Hitachi
       physical id: 0
       bus info: scsi@0:0.0.0
       logical name: /dev/sda
       version: MH4O
       serial: MRH403M4GS551Y
       size: 55GiB (60GB)
       capabilities: partitioned partitioned:dos
       configuration: ansiversion=5 signature=cccdcccd
  *-cdrom
       description: DVD reader
       product: UJDA755yDVD/CDRW
       vendor: MATSHITA
       physical id: 1
       bus info: scsi@1:0.0.0
       logical name: /dev/cdrom
       logical name: /dev/cdrw
       logical name: /dev/dvd
       logical name: /dev/scd0
       logical name: /dev/sr0
       version: 1.71
       capabilities: removable audio cd-r cd-rw dvd
       configuration: ansiversion=5 status=nodisc

The first section that’s returned is called -disk. Here’s you’ll see the vendor: Hitachi, the product number, HTS726060M9AT00, and my serial number: MRH403M4GS551Y.

Command #2: smartctl

The next tool that would give this type of info is called smartctl. It’s a tool that’s part of the smartmontool package. You may be familiar with the acronym S.M.A.R.T.. The acronym stands for: Self-Monitoring, Analysis, and Reporting Technology. This is a standard that most modern disks have in which vital statistics about a disk drive are provided through a standard API. Here’s how to install it.

1
yum install smartmontools

…and once installed you can use the bundled in tool smartctl like so:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# smartctl example
 
% smartctl -i /dev/sda
smartctl version 5.38 [i386-redhat-linux-gnu] Copyright (C) 2002-8 Bruce Allen
Home page is http://smartmontools.sourceforge.net/
 
=== START OF INFORMATION SECTION ===
Model Family:     Hitachi Travelstar 7K60
Device Model:     HTS726060M9AT00
Serial Number:    MRH403M4GS551Y
Firmware Version: MH4OA6BA
User Capacity:    60,011,642,880 bytes
Device is:        In smartctl database [for details use: -P show]
ATA Version is:   6
ATA Standard is:  ATA/ATAPI-6 T13 1410D revision 3a
Local Time is:    Mon Sep 21 00:03:50 2009 EDT
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

Command #3: hdparm

Another way that I’ve used to get at hard drive meta data is with the command hdparm. This is probably the oldest way, at least that I’m familiar with, for getting at hard drive meta data. To install it:

1
yum install hdparm

Using it is simply:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# hdparm example
 
% hdparm -i /dev/sda
 
/dev/sda:
 
 Model=HTS726060M9AT00                         , FwRev=MH4OA6BA, SerialNo=      MRH403M4GS551Y
 Config={ HardSect NotMFM HdSw>15uSec Fixed DTR>10Mbs }
 RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=4
 BuffType=DualPortCache, BuffSize=7877kB, MaxMultSect=16, MultSect=?0?
 CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=117210240
 IORDY=on/off, tPIO={min:240,w/IORDY:120}, tDMA={min:120,rec:120}
 PIO modes:  pio0 pio1 pio2 pio3 pio4 
 DMA modes:  mdma0 mdma1 mdma2 
 UDMA modes: udma0 udma1 udma2 udma3 udma4 *udma5 
 AdvancedPM=yes: mode=0xC0 (192) WriteCache=enabled
 Drive conforms to: ATA/ATAPI-6 T13 1410D revision 3a:  ATA/ATAPI-2,3,4,5,6
 
 * signifies the current active mode

Command #4: lsscsi

Here’s another tool, lsscsi, that I’ve used off and on to get at hard drive meta data. It’s probably the least known of all the tools mentioned here. Installation is the same as the others:

1
yum install lsscsi

It’s usage is pretty much in-line with the other commands too:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# lsscsi example
 
% lsscsi -lll -vvv
 sysfsroot: /sys
[0:0:0:0]    disk    ATA      HTS726060M9AT00  MH4O  /dev/sda
  device_blocked=0
  iocounterbits=32
  iodone_cnt=0x92983
  ioerr_cnt=0x4f
  iorequest_cnt=0x92983
  queue_depth=1
  queue_type=none
  scsi_level=6
  state=running
  timeout=60
  type=0
  dir: /sys/bus/scsi/devices/0:0:0:0  [/sys/devices/pci0000:00/0000:00:1f.1/host0/target0:0:0/0:0:0:0]
[1:0:0:0]    cd/dvd  MATSHITA UJDA755yDVD/CDRW 1.71  /dev/sr0
  device_blocked=0
  iocounterbits=32
  iodone_cnt=0xa0f7
  ioerr_cnt=0x0
  iorequest_cnt=0x283a7
  queue_depth=1
  queue_type=none
  scsi_level=6
  state=running
  timeout=0
  type=5
  dir: /sys/bus/scsi/devices/1:0:0:0  [/sys/devices/pci0000:00/0000:00:1f.1/host1/target1:0:0/1:0:0:0]

Command #4: /dev/disk/by-id directory

Finally you can get the manufacturer’s product number & serial number can be had by going directly to the /dev directory, specifically here: /dev/disk/by-id. In the resulting output you’ll see 2 important substrings. The first, HTS726060M9AT00, is he product number while the second, MRH403M4GS551Y, is the serial number.

1
2
3
4
5
6
7
8
9
# /dev/disk/by-id example
 
% ls -1 /dev/disk/by-id
ata-HTS726060M9AT00_MRH403M4GS551Y
ata-HTS726060M9AT00_MRH403M4GS551Y-part1
ata-HTS726060M9AT00_MRH403M4GS551Y-part2
scsi-SATA_HTS726060M9AT00_MRH403M4GS551Y
scsi-SATA_HTS726060M9AT00_MRH403M4GS551Y-part1
scsi-SATA_HTS726060M9AT00_MRH403M4GS551Y-part2

NOTE: For further details regarding my one-liner blog posts, check out my one-liner style guide primer.

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>