Home » Linux » Tips » Linux Check Disk

Check Disk Health in Linux/Ubuntu [How To / Guide]

Concerned that you have a failing hard drive? Make a backup. Then, use these Linux tools to check your disk/drive.

Not concerned that you have a failing drive? Back up anyway. It could be failing, and you don’t know it. Or it could get stolen. Or a meteorite could hit it.

Back. Up. Your. Files.

What is SMART?

S.M.A.R.T. (Self-Monitoring, Analysis, and Reporting Technology) is the system most hard disks use to report their health to the installed system.

This information can be queried to find out whether a drive is reporting any issues.

Using smartmontools/smartctl

The smartmontools contains the smartctl package, which can query the SMART status of a physical hard drive.

You can install it on Ubuntu and Debian based systems by running:

sudo apt install smartmontools

Once installed, you provide it with the path to the device name for your hard disk, and it queries the SMART status of the drive and outputs the results:

sudo smartctl -a /dev/sda

Above, the -a option is passed, telling smartctl to print all available SMART information for that disk.

/dev/sda is the path to the hard disk you want to check the health of. If you don’t know what this is, you can find a list of disks that can be queried by running:

sudo smartctl --scan

Most commands in this article are run using sudo as they require root/administrative privileges.

You can view the full user manual for smartmontools and smartctl by running:

man smartctl

Checking Using badblocks

The badblocks tools come pre-installed on many distributions, including Ubuntu. It will check for bad blocks on your disk.

block (or sector) is an area of the physical storage device where data is stored. badblocks will scan your disk block by block; if a block is damaged, it is marked as bad -, and the system actively avoids storing data on that part of the hard disk. When it’s done, you’ll get a full report on how many bad blocks were found.

sudo badblocks -v /dev/sda

Above, the -v option is used, which tells badblocks to be verbose and output as much information as possible while it is running. Finally,/dev/sda is the path to the device to be checked.

Running badblocks may take quite a while, depending on the size of the disk. However, once completed, you will receive a report on how many bad blocks or sector was found – which can be a good indicator of whether your disk has been damaged.

You can view the full user manual for backblocks by running:

man badblocks

Viewing SMART Status in a GUI Using gsmartcontrol

If you want to view the information provided by smartctl, but want to view it in a graphical window, you can use gsmartcontrol. Install it by running:

sudo apt install gsmartcontrol

You will be presented with a window containing a list of devices you can select:

GsmartControl - Linux Check Disk
GsmartControl – Listing Disks

…each can be clicked on to reveal SMART data, which can be inspected and exported.

Conclusion

Don’t bet on any of these tools. Drives fail ungracefully. Mechanical drives can jam up after being bumped at just the right angle. Power surges can happen. Cars can fly off of roads, bounce off of trees and crash through your house and destroy your computers. Please make a backup, and keep it somewhere safe.

SHARE:
Photo of author
Author
I'm Brad, and I'm nearing 20 years of experience with Linux. I've worked in just about every IT role there is before taking the leap into software development. Currently, I'm building desktop and web-based solutions with NodeJS and PHP hosted on Linux infrastructure. Visit my blog or find me on Twitter to see what I'm up to.

1 thought on “Check Disk Health in Linux/Ubuntu [How To / Guide]”

  1. Cars flying through our windows is not in our CFP (Catastrophic Failure Plan).
    I’ll have it added.
    Thanks!

    Reply

Leave a Comment