There mainly two reasons for scanning a computer hard disk: one is to examine it for filesystem inconsistencies or errors that can result from persistent system crashes, improper closure of critical system software and more significantly by destructive programs (such as malware, viruses etc).
And another is to analyze its physical condition, where we can check a hard disk for bad sectors resulting from physical damage on the disk surface or failed memory transistor.
In this article, we will review a mix of GUI and terminal based disk scanning utilities for Linux.
In case you notice any unusual behavior from a computer hard disk or a particular partition, one of the first things you can always investigate is filesystem inconsistency or errors and there is no other better utility for performing this other than fsck.
1. fsck – Filesystem Consistency Check
fsck is a system utility used to check and optionally repair a Linux filesystem. It is a front-end for several filesystem checkers.
Warning: Try out fsck commands on test Linux servers only, unless you know what you’re doing..
Always unmount a partition first before you can run fsck on it.
$ sudo unmount /dev/sdc1 $ sudo fsck -Vt vfat /dev/sdc1
In the command below, the switch:
-t– specifies the filesystem type.
-V– enables verbose mode.
You can find detailed usage instructions in the fsck man page:
$ man fsck
Once you have performed filesystem inconsistency tests, you proceed to carry out physical condition assessments.
badblocks is a utility for scanning bad blocks or bad sectors in hard disks. Assuming you detect any bad blocks on your hard disk, you can use it together with fsck or e2fsck to instruct the kernel not to use the bad blocks.
For more information on how to check bad blocks using badblock utility, read: How to Check Bad Sectors or Bad Blocks on Hard Disk in Linux.
3. S.M.A.R.T System Utilities
S.M.A.R.T (Self-Monitoring, Analysis and Reporting Technology) is a system built into nearly all modern ATA/SATA and SCSI/SAS hard disks as well as solid-state disks.
It collects in-depth information about a supported hard disk and you can get that data using the utilities below.
smartctl is one of the two utilities under the smartmontools package. It is a command line utility which controls and monitors the S.M.A.R.T system.
To install smartmontools package, run the applicable command below for your distro:
$ sudo apt-get install smartmontools #Debian/Ubuntu systems $ sudo yum install smartmontools #RHEL/CentOS systems
The following is an example of a smartctl command for reporting hard disk partition health where the option
-H helps to show the general partition health condition after a self-test:
$ sudo smartctl -H /dev/sda6
Look through the smartctl man page for more usage guidelines:
$ man smartctl
There is a GUI front-end for smartctl called gsmartcontrol which can be installed as follows:
$ sudo apt-get install gsmartcontrol #Debian/Ubuntu systems $ sudo yum install gsmartcontrol #RHEL/CentOS systems
ii. Gnome Disk Utility( or Disks)
Gnome disk utility offers a GUI for doing all the partition management related tasks such as creating, deleting, mounting partitions and beyond. It comes pre-installed in majority of mainstream Linux systems such as Ubuntu, Fedora, Linux Mint and others.
To use it on Ubuntu, open the Dash and search for Disks, on Linux Mint, open Menu and search for Disks and on Fedora, click on Activities type Disks.
More importantly, it can as well provide S.M.A.R.T data and effect self-tests as in the following interface.
That’s it! In this article, we reviewed hard disk scanning utilities for Linux operating system. You can share with us any utilities/tools for the same purpose, that are not mentioned in the list above or ask any related questions all in the comments.