Tech Tip: Retrieve Disk Info from the Command Line

 in

You can use the following command line tools to retrieve the make and model of your hard drives without the need to open up your system.

First, you need the device names of your disks, for this you can use df or cat /proc/partitions. Example device names are names such as /dev/hda or /dev/sdb. For the following examples, where applicable, I will use /dev/sda as my disk device.

Use the lshw command:

$ lshw -class disk
...
-disk:0
       product: ST3250310NS
       vendor:  Seagate
       version: SN04
       serial:  9SF0000TH
       size:    232GiB (250GB)

Use the smartctl command:

$ smartctl -i /dev/sda
...
Device Model:     ST3250310NS
Serial Number:    9SF0000TH
Firmware Version: SN04
...

Note: You may need to install the 'smartmontools' package, your output will vary depending on smartctl version and disk make/model.

Use the hdparm command:

$ hdparm -i /dev/sda

/dev/sda:

 Model=ST3250310NS, FwRev=SN04, SerialNo=9SF0000TH
...

Use the hwinfo command:

$ hwinfo --disk
...
Model:     "ST3250310NS"
Device:    "ST3250310NS"
Revision:  "SN04"
Serial ID: "9SF0000TH"
...

Note: You may need to install the 'hwinfo' package.

Note, you will need to be root to get the full output from these commands.

And one additional way that you can determine the model and serial number of your disk:

$ ls /dev/disk/by-id

ata-ST3250310NS_9SF0000TH
ata-ST3250310NS_9SF0000TH-part1
ata-ST3250310NS_9SF0000TH-part2
ata-ST3250310NS_9SF0000TH-part3

Here the model number is ST3250310NS, and the serial number is 9SF0000TH.

______________________

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

There is some error while

Catherine Thompson's picture

There is some error while displaying page. I can't able to read...... Help!!!!

here's a "one-liner" that

Anonymous's picture

here's a "one-liner" that makes use of standard utils (find, grep, etc.) when the above commands aren't available or are lacking:


for file in $(find /sys/block/[sh][dr]*/device/ /sys/block/[sh][dr]*/ -maxdepth 1 2>/dev/null|egrep '(vendor|model|/size|/sys/block/[sh][dr]./$)'|sort); do [ -d $file ] && echo -e "\n -- DEVICE $(basename $file) --" && continue; grep -H . $file|sed -e 's|^/sys/block/||;s|/d*e*v*i*c*e*/*\(.*\):| \1 |'|awk '{if($2 == "size") {printf "%-3s %-6s: %d MB\n", $1,$2,(($3 * 512)/1048576)} else {printf "%-3s %-6s: ", $1,$2;for(i=3;i<NF;++i) printf "%s ",$i;print $(NF) };}';done

Yowser

Mitch Frazier's picture

For better viewing:

for file in \
        $(find /sys/block/[sh][dr]*/device/ /sys/block/[sh][dr]*/ -maxdepth 1 2>/dev/null | \
              egrep '(vendor|model|/size|/sys/block/[sh][dr]./$)'|sort)
do
    [ -d $file ] && \
        echo -e "\n -- DEVICE $(basename $file) --" && \
        continue

    grep -H . $file | \
        sed -e 's|^/sys/block/||;s|/d*e*v*i*c*e*/*\(.*\):| \1 |' | \
        awk ' {
                  if ( $2 == "size" ) {
                      printf "%-3s %-6s: %d MB\n", $1,$2,(($3 * 512)/1048576)
                  }
                  else {
                      printf "%-3s %-6s: ", $1,$2
                      for ( i=3; i

p.s. A "one liner"...? Don't be afraid of the guys in the white coats, they're here to help.

Mitch Frazier is an Associate Editor for Linux Journal.

they're coming to take me

Anonymous's picture

they're coming to take me away...ha ha ho ho hee hee...

Some others

Chris Cox's picture

On newer implementation of the kernel, sysfs will have vendor, model, rev at /sys/block/sda/ and /sys/block/sda/device...

sginfo -a /dev/sda
can show a lot of info

Just some other options...
http://www.ntlug.org/Articles/ExploringHardware

White Paper
Fabric-Based Computing Enables Optimized Hyperscale Data Centers

Today’s modular x86 servers are compute-centric, designed as a least common denominator to support a wide range of IT workloads. Those generic, virtualized IT workloads have much different resource optimization requirements than hyperscale and cloud applications. They have resulted in a “one size fits all” enterprise IT architecture that is not optimized for a specific set of IT workloads, and especially not emerging hyperscale workloads, such as web applications, big data, and object storage. In this report, you will learn how shifting the focus from traditional compute-centric IT architectures to an innovative disaggregated fabric-based architecture can optimize and scale your data center.

Learn More

Sponsored by AMD

White Paper
Red Hat White Paper: Using an Open Source Framework to Catch the Bad Guy

Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6

Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.

Learn more about catching the bad guy in this free white paper.

Learn More

Sponsored by DLT Solutions