Hardware

Gather Storage Disk Information With ‘smartctl’

This will be a fairly universal article, useful for various distros, for those who want to gather storage disk information with smartctl. This is not a very taxing article, and more could be written, but we’ll simply be using smartctl to gather basic storage device information.

Habit means I want to type ‘hard disk’. I’ll refrain from doing so. I guess I could call them ‘storage drives’ but I’m just going to call them ‘storage disks’, or ‘disk’ when I am referring to the singular.

This isn’t going to get you information about the health of your storage disks or anything like that. Depending on the disk, it will give you information about things like the physical size, trim status, serial number, RPM (for spinning disks), and things like that.

The tool we’ll be using is smartctl, but that’s installed by installing smartmontools. This is going to be an easy install for many distros and I’ll try to detail that as best as I am able.

smartctl:

The tool we’ll be using is smartctl and it’s a terminal-based application. This tool is useful for a variety of things. We’ll just be gathering basic information about our storage drives. 

If you had smartctl installed already, you could check the man page. Doing so would reveal that the application is described like so:

smartctl – Control and Monitor Utility for SMART Disks

I suppose this could be considered controlling the drives (they’re not all disks anymore) but it’s definitely the tool for the job. Trust me on this! I wouldn’t steer you wrong, at least not intentionally. Oh, I do make mistakes, but they’re mostly harmless.

We’ve previously used this tool. Here’s a couple of articles for you:

How To: Check A Disk For Errors
How To: Use S.M.A.R.T. To Check Disk Health

So, in the weirdness of weirdness, if you want to use smartctl, you have to first install smartmontools. So, let’s cover that…

smartmontools:

First, you’re going to need to install smartmontools. We’ll cover how to do this, but it will be done via the terminal. You can use your GUI installer or you can (more often than not) just press CTRL + ALT + T and your default terminal will open.

With your terminal now open, pick the correct command to match your distro:

Debian/Ubuntu/etc:

sudo apt install smartmontools

OpenSUSE/SUSE/etc:

sudo zypper install smartmontools

RHEL/CentOS/etc:

sudo yum install smartmontools

Arch/Manjaro/etc:

sudo pacman -S smartmontools

If you use a mainstream distro, one of the above commands should install smartmontools and give you access to smartctl. There are other distros out there, but I think I’ve covered those appropriately.

Find Storage Information In Linux:

From here on out, the rest is pretty easy. With smartmontools installed, you can check the man page with this command:

man smartctl

The flag we’re interested in would be the -i flag.

Before we go any further, we must first identify the disks we want to learn more about. For that, we’ll run the following command: 

lsblk

Here’s an example output:

$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda      8:0    0 476.9G  0 disk 
├─sda1   8:1    0   512M  0 part /boot/efi
└─sda2   8:2    0 476.4G  0 part /
sdb      8:16   1  58.6G  0 disk 
└─sdb1   8:17   1  58.6G  0 part /media/kgiii/DISCOVERY
sdc      8:32   0   3.6T  0 disk 
├─sdc1   8:33   0 991.1G  0 part /media/kgiii/elements1
├─sdc2   8:34   0 984.6G  0 part /media/kgiii/elements2
├─sdc3   8:35   0 976.7G  0 part /media/kgiii/elements3
└─sdc4   8:36   0 773.6G  0 part /media/kgiii/elements4
sr0     11:0    1  1024M  0 rom  

We’re not interested in partitions. We’re just interested in physical disks. (Now that I’m this far through the article, I should have stuck with ‘drives’ instead of disks.) 

If you pay attention to the output, you’ll see that the information we’re after is stuff like sda, sdb, or sdc. Those are all in the /dev/ directory which means that we can check storage disk information with this syntax:

sudo smartctl -i /dev/<drive_ID>

Or, to provide an example…

sudo smartctl -i /dev/sda

This is a pretty good way to gather storage disk information. Here’s an example of the output from the previous command:

$  sudo smartctl -i /dev/sda
smartctl 7.2 2020-12-30 r5155 [x86_64-linux-5.15.0-91-generic] (local build)
Copyright (C) 2002-20, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Device Model:     TEAM T253X2512G
Serial Number:    TPBF2006290040203664
Firmware Version: S1127B0
User Capacity:    512,110,190,592 bytes [512 GB]
Sector Size:      512 bytes logical/physical
Rotation Rate:    Solid State Device
Form Factor:      2.5 inches
TRIM Command:     Available, deterministic, zeroed
Device is:        Not in smartctl database [for details use: -P showall]
ATA Version is:   ACS-2 T13/2015-D revision 3
SATA Version is:  SATA 3.2, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is:    Tue Jan 16 21:46:59 2024 EST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

See? All sorts of information is available behind a simple terminal command! This is even something you can memorize in just a few minutes.

Closure:

I’m not sure when you’ll want to know this information, but it’s information and it is information that’s easily available to you. You simply need to install an application and run the commands listed above. I’m sure you can figure this out. 

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

KGIII

Retired mathematician, residing in the mountains of Maine. I may be old and wise, but I am not infallible. Please point out any errors. And, as always, thanks again for reading.

Recent Posts

Enable/Disable Your Network Interface

Today we'll cover one way to enable or disable your network interface in the Linux…

7 months ago

Check Your NIC Speed In The Terminal

Today's exercise is a nice and simple exercise where we check your NIC speed in…

7 months ago

Easily Monitor Your Wireless Connection

Have you ever wanted to easily monitor your wireless connection? Well, now you can learn…

7 months ago

Count The Files In A Directory

I think I've covered this before with the ls command but this time we'll count…

7 months ago

Get System Information With The ‘uname’ Command In Linux

Today we'll be learning about a basic Linux command that's known as 'uname' and it…

7 months ago

hardinfo Has Been Rebooted As hardinfo2

If you've used hardinfo in the past, it may interest you to know that hardinfo…

7 months ago