How to check Hard Drive Disk Health in GNU/Linux
So, I recently purchased a new (used, but new to me) laptop, that had a 1TB 5400RPM Hard Disk in it, granted the laptop is fairly powerful and capable of modern gaming, rendering, and number crunching thanks to a 4th generation i7 CPU and a Dedicated 2GB GDDR5 GPU. However, the HDD seemed to be running awfully slowly, even for a 5400RPM drive.
Iâ€™ve been using strictly Solid State Drives for a number of years now, so I admit there was always the possibility of me just having become spoiled, but I thought that perhaps I should look into the health of the drive; after all, a laptop with specs like that should in my eyes run faster so better safe than sorry. This raised the thought to me that perhaps I should write a quick how-to on this procedure for the Ghacks.net community.
This tutorial is done via CLI only, however, there are tools that do the job as well I will briefly cover at the end of this.
Checking the hard drive health in Linux
The tool we are going to be using is called smartmontools (which is also available for Windows and OS X).
The smartmontools package contains two utility programs (smartctl and smartd) to control and monitor storage systems using the Self-Monitoring, Analysis and Reporting Technology System (SMART) built into most modern ATA/SATA, SCSI/SAS and NVMe disks. In many cases, these utilities will provide advanced warning of disk degradation and failure. Smartmontools was originally derived from the Linux â€‹smartsuite package and actually supports ATA/ATAPI/SATA-3 to -8 disks and SCSI disks and tape devices.
- For Ubuntu/Linux Mint users: sudo apt install smartmontools
- For Arch users: sudo pacman -S smartmontools
Generally speaking smartmontools is available on most distributions, just install with your given package manager using the package name â€œsmartmontoolsâ€
Once that is installed, we need to figure out which drive our questionable one is:
sudo fdisk -l
This will give you a list of all drives and partitions. If you are only using one drive within your machine then itâ€™s going to list /dev/sda and its various partitions. If you have multiple drives, youâ€™ll need to use a little bit of common sense in seeing which drive the one you want to inspect, has what on it, and itâ€™s associated listing such as /dev/sdb or /dev/sdc etc.
Once we know the drive we want to check out, there are three tests that we can run, depending on how concerned you are:
- A short test, usually sufficient at detecting issues
- A longer test if you are more concerned that examines the entire disk surface
- A conveyance test which is used to test if damages occurred during transportation of the device from the manufacturer.
The next step is to find out what types of tests our disk supports, as well as an estimate to how long the tests will take to run.
sudo smartctl -c /dev/sdX (replace X with the appropriate letter)
You're going to be given a large amount of output as seen in this screenshot. I've highlighted the areas that were relevant to me for this test; the time estimates, and the fact that my disk does NOT support a conveyance test.
I oped to run the shorter test, just because I heard no clicks or other telltale signs that the hard disk was actually on itâ€™s last legs besides the speed; to which I again state I may just be spoiled by SSDs. You are more than welcome to run that which you feel needed.
The commands for the various tests are (replace sdX with the drive that you want to test)
- Short: sudo smartctl -t short /dev/sdX
- Long: sudo smartctl -t long /dev/sdX
- Conveyance: sudo smartctl -t conveyance /dev/sdX
Note: You will not get any scrolling output for your test beyond being told how long the test will take. If you're running the long test, you may have to wait an hour or two or longer.
Once the test is finished, it's time to get out result!
sudo smartctl -H /dev/sdX
Hopefully you'll see this:
If not, then either some more digging may need to be done, or it might just be time to replace the drive in question.
There are other options for those of you who avoid the command line, such as the very popular and well known tool gnome-disk-utility (also known as 'disks' by some desktop environments.)
There are numerous other free and paid utilities out there, but I'm not here to advertise, as both of these utilities have served me well in the past for doing quick checks.
I use GSmartControl which is a GUI that runs smartmontools and is available for most distros in their repositories and is very easy to use. Shows you details of the hard drive selected (type, serial number, model, firmware version, etc.), shows all the S.M.A.R.T. attributes and capabilities supported by the drive, and allows to select the short or long tests.
I agree with Richard. Disks (gnome-disks) is good enough for a quick view and check. GSmartControl is more detailed and extensive, an excellent GUI for smartctl in my opinion.
Another GUI for smartmontools is through Webmin, a browser-based system configuration utility. It includes a handy module that taps into a drive’s SMART.
If your hdd or partition is formatted with ext2/ext3/ext4 you can also use e2fsprogs which, like these file systems, is developed and maintained by Theodore Ts’o.
The program(s) (it’s actually a number of very small tools) is straightforward to use from the console and has many useful options. I have set mine up to run a thorough hdd-check once each 100 boot-ups …
tune2fs -c 100 /dev/sda1 (change your device accordingly)
… so, each couple of weeks the boot procedure takes a little longer. But that’s ok.
PartEd Magic would be worth a feature, I think it’s indispensable.
A few more suggestions here: https://www.howtogeek.com/howto/37659/the-beginners-guide-to-linux-disk-utilities/
I use the gnome disk utility but its alright informing me of bad sectors but can they fix them.?.these are useless in that respect.
THANK YOU. very helpful. Q. Can I run this utility on more than on hard drive at once, i.e. start it for one, then immediately for another while the first test is running?
In Windows 7 was implemented the best system for checking HDD drives and even Sata 2/3 /, when you go into my computer you right-click on the disk and select the properties, go to the service, perform the scan, the following options are available: 1) Automatically correct system errors 2) Scan and repair damaged sectors. in Windows 10 do you think it’s all included? Removed … you run the Automatically fix system errors – on Windows 2000 / XP / Windows Vista / 7 / test automatically and you will be notified that the system is busy and can not check the disk, enable the next time you restart the computer, check (in the scheduler) and there will be a blue screen with verification depending on the version of Windows / and will check well between others, for which I liked Microsoft, but for some reason I forgot or specially removed it in Windows 10 and maybe in 8 / 8.1 such a function, of course the best way to restore these functions to save many users from the Bad Sector to the At the initial stage, do not you agree? Ð’ Windows 7 Ð±Ñ‹Ð»Ð° Ñ€ÐµÐ°Ð»Ð¸Ð·Ð¾Ð²Ð°Ð½Ð° ÑÐ°Ð¼Ð°Ñ Ð»ÑƒÑ‡ÑˆÐ°Ñ ÑÐ¸ÑÑ‚ÐµÐ¼Ð° Ð¿Ð¾ Ð¿Ñ€Ð¾Ð²ÐµÑ€ÐºÐµ HDD Ð´Ð¸ÑÐºÐ¾Ð² Ð¸ Ð´Ð°Ð¶Ðµ Sata 2/3/ , ÐºÐ¾Ð³Ð´Ð° Ð·Ð°Ñ…Ð¾Ð´Ð¸ÑˆÑŒ Ð² Ð¼Ð¾Ð¹ ÐºÐ¾Ð¼Ð¿ÑŒÑŽÑ‚ÐµÑ€ Ð½Ð°Ð¶Ð¸Ð¼Ð°ÐµÑˆÑŒ Ð¿Ñ€Ð°Ð²Ð¾Ð¹ ÐºÐ½Ð¾Ð¿ÐºÐ¾Ð¹ Ð¼Ñ‹ÑˆÐ¸ Ð½Ð° Ð´Ð¸ÑÐº Ð¸ Ð²Ñ‹Ð±Ð¸Ñ€Ð°ÐµÑˆÑŒ ÑÐ²Ð¾Ð¹ÑÑ‚Ð²Ð°, Ð¿ÐµÑ€ÐµÑ…Ð¾Ð´Ð¸ÑˆÑŒ Ð² ÑÐµÑ€Ð²Ð¸Ñ, Ð²Ñ‹Ð¿Ð¾Ð»Ð½Ð¸Ñ‚ÑŒ Ð¿Ñ€Ð¾Ð²ÐµÑ€ÐºÑƒ, Ð”Ð¾ÑÑ‚ÑƒÐ¿Ð½Ñ‹ ÑÐ»ÐµÐ´ÑƒÑŽÑ‰Ð¸Ðµ Ð²Ð°Ñ€Ð¸Ð°Ð½Ñ‚Ñ‹: 1)ÐÐ²Ñ‚Ð¾Ð¼Ð°Ñ‚Ð¸Ñ‡ÐµÑÐºÐ¸ Ð¸ÑÐ¿Ñ€Ð°Ð²Ð»ÑÑ‚ÑŒ ÑÐ¸ÑÑ‚ÐµÐ¼Ð½Ñ‹Ðµ Ð¾ÑˆÐ¸Ð±ÐºÐ¸ 2)ÐŸÑ€Ð¾Ð²ÐµÑ€ÑÑ‚ÑŒ Ð¸ Ð²Ð¾ÑÑÑ‚Ð°Ð½Ð°Ð²Ð»Ð¸Ð²Ð°Ñ‚ÑŒ Ð¿Ð¾Ð²Ñ€ÐµÐ¶Ð´ÐµÐ½Ð½Ñ‹Ðµ ÑÐµÐºÑ‚Ð¾Ñ€Ð°. Ð² Windows 10 Ð²Ñ‹ Ð´ÑƒÐ¼Ð°ÐµÑ‚Ðµ Ð²ÑÑ‘ Ð²ÐºÐ»ÑŽÑ‡ÐµÐ½Ð¾? Ð£Ð±Ñ€Ð°Ð»Ð¸… Ð²Ñ‹ Ð·Ð°Ð¿ÑƒÑÑ‚Ð¸Ñ‚Ðµ Ð¿Ñ€Ð¾Ð²ÐµÑ€ÐºÑƒ ÐÐ²Ñ‚Ð¾Ð¼Ð°Ñ‚Ð¸Ñ‡ÐµÑÐºÐ¸ Ð¸ÑÐ¿Ñ€Ð°Ð²Ð»ÑÑ‚ÑŒ ÑÐ¸ÑÑ‚ÐµÐ¼Ð½Ñ‹Ðµ Ð¾ÑˆÐ¸Ð±ÐºÐ¸ – Ð½Ð° Windows 2000/XP/Windows Vista/7/ Ð¸ Ð²Ð°Ð¼ Ð²Ñ‹Ð´Ð°ÑÑ‚ ÑƒÐ²ÐµÐ´Ð¾Ð¼Ð»ÐµÐ½Ð¸Ðµ Ð¾ Ñ‚Ð¾Ð¼, Ñ‡Ñ‚Ð¾ ÑÐ¸ÑÑ‚ÐµÐ¼Ð° Ð·Ð°Ð½ÑÑ‚Ð° Ð¸ Ð½Ðµ Ð¼Ð¾Ð¶ÐµÑ‚ Ð¿Ñ€Ð¾Ð²ÐµÑ€Ð¸Ñ‚ÑŒ Ð´Ð¸ÑÐº, Ð²ÐºÐ»ÑŽÑ‡Ð¸Ñ‚ÑŒ Ð¿Ñ€Ð¸ ÑÐ»ÐµÐ´ÑƒÑŽÑ‰Ð¸Ð¹ Ð¿ÐµÑ€ÐµÐ·Ð°Ð³Ñ€ÑƒÐ·ÐºÐµ ÐºÐ¾Ð¼Ð¿ÑŒÑŽÑ‚ÐµÑ€Ð° Ð¿Ñ€Ð¾Ð²ÐµÑ€ÐºÑƒ (Ð² Ð¿Ð»Ð°Ð½Ð¸Ñ€Ð¾Ð²Ñ‰Ð¸Ðº) Ð¸ Ð±ÑƒÐ´ÐµÑ‚ ÑÐ¸Ð½Ð¸Ð¹ ÑÐºÑ€Ð°Ð½ Ñ Ð¿Ñ€Ð¾Ð²ÐµÑ€ÐºÐ¾Ð¹ Ð² Ð·Ð°Ð²Ð¸ÑÐ¸Ð¼Ð¾ÑÑ‚Ð¸ Ð¾Ñ‚ Ð²ÐµÑ€ÑÐ¸Ð¸ Windows/ Ð¸ Ð¼ÐµÐ¶Ð´Ñƒ Ð¿Ñ€Ð¾Ñ‡ÐµÐ¼ Ð¿Ñ€Ð¾Ð²ÐµÑ€Ð¸Ñ‚ Ñ…Ð¾Ñ€Ð¾ÑˆÐ¾, Ð·Ð° Ñ‡Ñ‚Ð¾ Ñ Ð»ÑŽÐ±Ð¸Ð» Microsoft, Ð½Ð¾ Ð¿Ð¾Ñ‡ÐµÐ¼Ñƒ Ñ‚Ð¾ Ð·Ð°Ð±Ñ‹Ð»Ð¸ Ð¸Ð»Ð¸ ÑÐ¿ÐµÑ†Ð¸Ð°Ð»ÑŒÐ½Ð¾ ÑƒÐ±Ñ€Ð°Ð»Ð¸ Ð² Windows 10 Ð° Ñ‚Ð¾ Ð¸ Ð¼Ð¾Ð¶ÐµÑ‚ Ð¸ Ð² 8/8.1 Ñ‚Ð°ÐºÑƒÑŽ Ñ„ÑƒÐ½ÐºÑ†Ð¸ÑŽ, ÐºÐ¾Ð½ÐµÑ‡Ð½Ð¾ Ð»ÑƒÑ‡ÑˆÐ¸Ð¹ Ð²Ð°Ñ€Ð¸Ð°Ð½Ñ‚ Ð²Ð¾ÑÑÑ‚Ð°Ð½Ð¾Ð²Ð¸Ñ‚ÑŒ ÑÑ‚Ð¸ Ñ„ÑƒÐ½ÐºÑ†Ð¸Ð¸, Ñ‡Ñ‚Ð¾Ð±Ñ‹ ÑÐ¿Ð°ÑÑ‚Ð¸ Ð¼Ð½Ð¾Ð³Ð¸Ñ… Ð¿Ð¾Ð»ÑŒÐ·Ð¾Ð²Ð°Ñ‚ÐµÐ»ÐµÐ¹ Ð¾Ñ‚ Ð‘Ð°Ð´ Ð¡ÐµÐºÑ‚Ð¾Ñ€Ð¾Ð² Ð½Ð° Ð½Ð°Ñ‡Ð°Ð»ÑŒÐ½Ð¾Ð¹ ÑÑ‚Ð°Ð´Ð¸Ð¸, Ñ€Ð°Ð·Ð²Ðµ Ð²Ñ‹ Ð½Ðµ ÑÐ¾Ð³Ð»Ð°ÑÐ½Ñ‹?