Tech Tip: Retrieve Disk Info from the Command Line


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
       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


 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


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



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


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)
    [ -d $file ] && \
        echo -e "\n -- DEVICE $(basename $file) --" && \

    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...

White Paper
Linux Management with Red Hat Satellite: Measuring Business Impact and ROI

Linux has become a key foundation for supporting today's rapidly growing IT environments. Linux is being used to deploy business applications and databases, trading on its reputation as a low-cost operating environment. For many IT organizations, Linux is a mainstay for deploying Web servers and has evolved from handling basic file, print, and utility workloads to running mission-critical applications and databases, physically, virtually, and in the cloud. As Linux grows in importance in terms of value to the business, managing Linux environments to high standards of service quality — availability, security, and performance — becomes an essential requirement for business success.

Learn More

Sponsored by Red Hat

White Paper
Private PaaS for the Agile Enterprise

If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.

Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.

Learn More

Sponsored by ActiveState