1. Overview

What’s the most direct way to find out if our filesystem runs on a Solid State Device (SSD) or an older and slower Hard Disk Drive (HDD)?

There are many elements of Linux storage. And one will find what seems like just as many tools to read and configure our storage. When we go looking for information, we find ourselves sifting through terms like “drive”, “block device”, “volume”, and “mount point.” To discover the hardware behind our filesystem, we will only need to know two things:

  1. What physical disk or block device we are looking at (from df)
  2. The hardware parameters of that disk (from hdparm)

In this tutorial, we’ll see how to find out if our files are on fast solid state media or a slower, mechanical drive.

2. What Disk Are We On, Anyway?

Let’s start off by checking our mounted volumes with df, the “disk free” command:

$ df -Th -x tmpfs
Filesystem                  Type     Size  Used Avail Use% Mounted on
/dev/sdb2                   ext4     228G  173G   44G  80% /
/dev/sdb1                   vfat     511M  6.3M  505M   2% /boot/efi
/dev/sdc1                   fuseblk  466G  352G  114G  76% /media/a/9EE8E134E8E10AFB1
/dev/mapper/wonder--vg-root ext4     902G   57G  799G   7% /media/a/450c0236-eea5-4a75

We use -T to show the filesystem type, -h to show the size in human-readable units, and -x tmpfs to exclude temporary filesystems. We only want physical drives.

From this, we can tell that our root filesystem is on a partition of the /dev/sdb drive. We also see an sdc drive and a ‘mapper’ LVM virtual volume group. If we get confused, we can use tools like mount and mountpoint to clarify where our filesystem maps to which drive partitions.

3. Using hdparm with Care

The “Hard Disk Parameters” command, hdparm, can be used to either get or set drive parameters. That means we can read all kinds of information from our drives. But in addition, it means we can change settings that may harm performance or destroy our data.

We’ll need to run hdparm as root. This means our actions may have immediate and direct consequences.

3.1. hdparm and Solid State Drives

Let’s say we want to find out more about the hardware behind our root filesystem. We remember that it’s on the sdb drive. So we can use hdparm with the -I option to ask for detailed information:

$ sudo hdparm -I /dev/sdb

/dev/sdb:

ATA device, with non-removable media
    Model Number:       Samsung SSD 840 EVO 250GB
...         

From these first few lines, we discover our disk drive has “SSD” in the name. That’s a pretty good indicator that it is indeed a Solid State Drive.

3.2. ‘Solid State’ Means No Moving Parts

But here’s another example of an SSD drive with a less human-readable name:

$ sudo hdparm -I /dev/sdc

/dev/sdc:

ATA device, with non-removable media
    Model Number:       WDC WDS500G2B0B-00YS70  
...

We could look up this model number. But there’s a quicker way if we search further down in hdparm‘s output:

$ sudo hdparm -I /dev/sdc | grep 'Nominal Media Rotation Rate'
    Nominal Media Rotation Rate: Solid State Device

What does “Nominal Media Rotation Rate” mean? Well, remember that we are trying to distinguish between two types of drives.

A Hard Disk Drive is a mechanical device. It reads and writes our data on rotating metal platters–what wags call “spinning rust.” This system is vulnerable to mechanical failure. But it’s also limited by how fast the reader arm (like a phonograph needle) can move along the spinning platters. How fast they spin is the “Rotation Rate.”

In contrast, a Solid State Drive stores our data on NAND flash memory, similar to a USB stick. There are no moving parts! Now, there are slower and faster kinds of SSDs. But the bottleneck is no longer in moving the data onto and off of the disk. It’s in getting it to the rest of the computer (the RAM).

Let’s check what hdparm has to say about a mechanical HDD:

$ sudo hdparm -I /dev/mapper/wonder--vg-root | grep 'Nominal Media Rotation Rate'
    Nominal Media Rotation Rate: 7200

This output tells us that this disk drive does have moving parts. The platters spin at 7200 rotations per minute (rpm).

In short, we check the “Nominal Media Rotation Rate” of our hard drive. If it’s a number, it’s a mechanical drive (HDD). If it says “Solid State Device”, it’s an SSD.

4. Conclusion

Linux will tell us a lot of information about our storage. So much information, it’s easy to get lost. In this article, we sift through all that information to reveal the hardware specifics of our storage.

First, we list our mounted drive devices with df.

Next, we carefully run the hdparm -I command as root.

And finally, we use grep to get right to the information we care about.