164

My SATA drive started clicking and I was unable to access the data. This is the hard drive in question:

HITACHI Deskstar T7K250 HDT722525DLA380 (0A31636) 250GB 7200 RPM 8MB Cache SATA 3.0Gb/s 3.5" Hard Drive -Bare Drive

It was not clicking loudly though, like a drive that has already gone bad. After tightening the connections to the hard drive, it stopped clicking and I was able to access the data again. I have started to move files off of the drive, but I think this drive might still be in good health.

I didn't find any data corruption and I haven't had any trouble accessing any files. I have never had an SATA drive fail before so I'm thinking that it could have just been the loose connections that was causing the problem.

What tests can I run on this drive to find out how healthy it is?

1
  • 1
    Oh, when I answered you hadn't mentioned that it was a deathstar. At least some of the Deskstar line has a very bad reputation for longevity and reliability. Bad enough that the failing drives are termed "deathstar". Aug 4, 2010 at 2:02

16 Answers 16

159
sudo smartctl -a /dev/sda | less

This will give you an abundance of information about your hard drive's health. The tool also permits you to start and monitor self tests of the drive.

If you want to do benchmarks / check all of the sectors to find one that is bad, you can find other tools for that, but smartctl is the first place to go for drive health status.

14
  • 7
    And Palimpsest (aka gnome-disk-utility) is a slick GUI app that gives the same info. Aug 3, 2010 at 9:28
  • 2
    palimpsest is notorious for often giving false positives.
    – vtest
    Sep 4, 2010 at 3:41
  • 8
    @vtest citation required
    – mgalgs
    Nov 5, 2014 at 18:32
  • 76
    For anyone who finds they don't have smartctl: it's probably under your package manager as "smartmontools". Jun 28, 2015 at 17:56
  • 8
    sudo apt-get install smartmontools on Ubuntu 14
    – mrgloom
    Oct 21, 2017 at 13:06
85

badblocks is one more useful utility; it shows the amount and location of bad blocks on your drive. Above is an example with an ongoing progress of currently scanned device:

sudo badblocks -v /dev/sda -s
8
  • 2
    what is the link with a possibly hardware failing hard drive?
    – tuk0z
    Oct 5, 2015 at 1:56
  • 4
    @lliseil Question is How to check the health of a hard drive
    – Emmanuel
    Mar 4, 2016 at 12:21
  • pacman -S e2fsprogs on arch
    – oddRaven
    Oct 1, 2017 at 21:41
  • 5
    @Emmanuel Yes... but at the cost of increased wear. For example, Seagate Surveillance drives are rated for around 180TB/year. Doing badblocks on a 10TB one will transfer 80TB of data. It really makes sense to do it before you start using it. If a block is particularly bad there is a good chance running badblocks in read only mode will trip the badblock and it'll get reported on smart... Also, badblocks takes ~96 hours to run on a WD Red 8TB, which is kind of annoying, especially if you lose power and aren't sure where you left off.
    – Ray Foss
    Feb 16, 2018 at 18:55
  • 2
    so badblocks -v seems to report bad block "numbers", one per line, e.g. 37754169, 37754170 ... . Knowing the bad blocks, what can then be done?
    – Abdull
    Oct 8, 2022 at 10:42
19

I see that no one has mentioned gsmartcontrol which is a GUI.

In Ubuntu you can install it with $ sudo apt-get install gsmartcontrol

If you launch sudo gsmartcontrol you see all the hard drives in your computer.

Then if you right click on a device and click View Details you see something like this.

You can get a lot of details in the different tabs here. You can also perform tests in the Perform Tests tab.

GSmartControl

1
  • Finally, this tool has given me all the info I needed. Many thanks ! Feb 7, 2020 at 18:14
18

If a HD starts to give you physical hints about an upcoming failure, no software will help. Yes, SMART exists and things like smartctl can read its results for you, but you shouldn't bet on it. SMART can be useful for detecting things like high temperatures or bad sectors, but if your HD starts to click or does not start up during the first try, it's time to

  • make sure you have backups
  • rush to nearest computer dealer, buy a new HD and copy everything there

When HD decides to fail, it will do it without a previous warning and Murphy's law says that the failure will happen during the most unwanted moment. So be prepared and backup & replace the disk NOW rather than waiting for the catastrophe.

3
  • Why not bet on S.M.A.R.T., provided it is properly supported by the HDD and its host? @Janne Pikkarainen
    – tuk0z
    Oct 5, 2015 at 1:52
  • 9
    This did nothing to answer OP's question. This is more lecture than answer
    – etherous
    Aug 25, 2017 at 2:40
  • 1
    @etherous You shall see beyond the apparent question. Actually this is the most accurate answer, as most software methods will fail to DETECT most PRE-failures. Feb 15, 2020 at 5:40
5

Try using SpinRite (It isn't free) but I have used many, many tools. Most tools make more damage than help, when I say damage, I mean "not taking good care of your information". This tool will check your drive and fix the bad sectors, while moving your information to secure sectors. It also is a preventing method for hard disk catastrophes

I strongly suggest risking on buying a fully tested product with a good background, than losing your so valuable information.

2
  • +1 For SpinRite. It is so fast and light, it has save many hard drives with crucial data. I recommend you give it a go.
    – Jose Elera
    Jan 21, 2013 at 8:33
  • 1
    SpinRite +crucial data in one sentence is bad idea unless the words 'do not' are in there too. Dec 29, 2022 at 13:49
4

Besides the already mentioned SMART status it might be important to mention that modern HDDs tend not to fail gracefully. Often from one day to the next you only hear a clicking sound or can't access the disk at all. So while your problem could also be caused by a loose cable be always prepared by having regular backups on a different disk.

4

Test environment: Permanent Live Ubuntu 16.04 USB made based on the thread How to Make Persistent Live Ubuntu of 16.04? Connect your HDD on your computer. Boot to the live Ubuntu. The GUI program gnome-disks which shows also bad-sectors and where you can do benchmarking of the discs and its different sectors. It is similar to the tools of smartmontools for sudo smartctl -a .... Example output of benchmarking my 500 GB disc where you see the read/write speed degenerates in time under heavy load

enter image description here

Other view: SMART Data & Self-Tests where I run short self-test. You can find temperature of the drive, and how many years/months/days your drive has had power on

enter image description here

1
  • Any idea why the "Smart Data and Self-Tests..." menu is disabled in sudo gnome-disks for disks that do have SMART (as shown by gsmartcontrol)? Feb 17, 2019 at 8:29
4

Output of smartctl is hard to read for me. gnome-disks pulls in GNOME which nowadays cannot live without NetworkManager.

I found skdump(part of libatasmart) which I able to understand. It produce also "Pretty" and "Good" columns alongside with Overall status:

Bad Sectors: 0 sectors
Powered On: 7.4 years
Power Cycles: 2144
Average Powered On Per Power Cycle: 1.3 days
Temperature: 33.0 C
Attribute Parsing Verification: Good
Overall Status: GOOD
ID# Name                        Value Worst Thres Pretty      Raw            Type    Updates Good Good/Past
  1 raw-read-error-rate         100    91    51   36          0x240000000000 prefail online  yes  yes 
  3 spin-up-time                 76    76    11   8.0 s       0x181f00000000 prefail online  yes  yes 
  4 start-stop-count             98    98     0   2173        0x7d0800000000 old-age online  n/a  n/a 
  5 reallocated-sector-count    100   100    10   0 sectors   0x000000000000 prefail online  yes  yes 
  7 seek-error-rate             100   100    51   0           0x000000000000 prefail online  yes  yes 
  8 seek-time-performance       100   100    15   n/a         0x072700000000 prefail offline yes  yes 
  9 power-on-hours               87    87     0   7.4 years   0xd1fd00000000 old-age online  n/a  n/a 
 10 spin-retry-count            100   100    51   0           0x000000000000 prefail online  yes  yes 
 11 calibration-retry-count     100   100     0   0           0x000000000000 old-age online  n/a  n/a 
 12 power-cycle-count            98    98     0   2144        0x600800000000 old-age online  n/a  n/a 
 13 read-soft-error-rate        100    91     0   36          0x240000000000 old-age online  n/a  n/a 
183 runtime-bad-block-total     100   100     0   0           0x000000000000 old-age online  n/a  n/a 
184 end-to-end-error            100   100     0   0           0x000000000000 prefail online  n/a  n/a 
187 reported-uncorrect          100   100     0   2540 sectors 0xec0900000000 old-age online  n/a  n/a 
188 command-timeout             100   100     0   0           0x000000000000 old-age online  n/a  n/a 
190 airflow-temperature-celsius  67    53     0   33.0 C      0x21000f210000 old-age online  n/a  n/a 
194 temperature-celsius-2        67    52     0   33.0 C      0x21000f220000 old-age online  n/a  n/a 
195 hardware-ecc-recovered      100   100     0   47099       0xfbb700000000 old-age online  n/a  n/a 
196 reallocated-event-count     100   100     0   0           0x000000000000 old-age online  n/a  n/a 
197 current-pending-sector      100   100     0   0 sectors   0x000000000000 old-age online  n/a  n/a 
198 offline-uncorrectable       100   100     0   0 sectors   0x000000000000 old-age offline n/a  n/a 
199 udma-crc-error-count        100   100     0   0           0x000000000000 old-age online  n/a  n/a 
200 multi-zone-error-rate       100   100     0   0           0x000000000000 old-age online  n/a  n/a 
201 soft-read-error-rate        100   100     0   0           0x000000000000 old-age online  n/a  n/a 

Though it states "GOOD" (Samsung HD103UJ). In output of smartctl I saw log with errors and you can see them under 187 (uncorrected errors) which indicates how much data I really lost. Seeing 7 (reallocated sectors) being at 0 is a bit unexpected for me.

4
  • sudo apt install -y libatasmart-bin Sep 2, 2022 at 4:46
  • I agree this is much easier to understand than smartctl Sep 2, 2022 at 4:47
  • ls /dev/sd* | grep 'sd.$' | xargs --delimiter '\n' --max-args=1 sudo skdump | grep Overall Sep 2, 2022 at 5:02
  • ls /dev/sd* | xargs -n 1 sudo skdump | grep -e power-on-hours -e Device - for power-on-hours Oct 14, 2022 at 15:53
1

HDDScan is a very handy/useful utility for scanning HDDs. It'll show any error most likely. However, you should also try vendor specific tools. (If you tell me your HDD's manufacturers (and model) I can link them here.)

3
  • 2
    Posted above. HDDScan looks like a good tool, but is there something like that for Linux?
    – tony_sid
    Aug 2, 2010 at 23:56
  • Well.. You didn't add Linux tag, nor what kind of architecture, which package based, etc. You can scan your harddrive with "e2fsck". Try typing "man fsck" / "man e2fsck" or "e2fsck --help" into the console and you'll see how to use it.
    – Apache
    Aug 3, 2010 at 6:02
  • 4
    e2fsck stands for filesystem check.
    – tuk0z
    Oct 5, 2015 at 1:53
1

http://en.wikipedia.org/wiki/S.M.A.R.T.

S.M.A.R.T. is a set standard for what you're describing. There are various applications out there to get the information from the HDD.

My favorite (and free) choice is SpeedFan.

1

I wonder why there is no complete answer on this page. Here are the two steps to recover bad blocks (why stop at scanning and get only numbers of bad blocks?):

Step one, collect numbers of bad blocks in file:

sudo badblocks -v /dev/sda1 > ~/bad_sectors.txt

Note, that I do not use the key -s that is normally used to show a progress indicator, we need to have only numbers in the file.

Step two, fix them (it is not repair; it just removes them from consideration while arranging data on drive): For extX filesystems:

sudo e2fsck -fccky /dev/sda1 

For FATxx:

sudo fsck -fccky /dev/sda1

Thats it. It alleviates the problem if bad sectors exist but are not growing in quantity rapidly.


These options meaning:

-f Force checking even if the file system seems clean.

-cc This option employs the use of badblocks(8) program to do a read-only scan for bad blocks. If there are any bad blocks they will be added to bad block "file" (inode) to prevent their use. If twice, then the bad block scan will be done using a non-destructive read-write test.

-k with -c option, any existing bad blocks in the bad blocks list are preserved with adding newly found.

-y Assume an answer of `yes' to all questions.


Also, deriving from the model of the HDD, I would recommend downloading and using the Hitachi Drive Fitness Test, which should work with the most HGST-legacy HDDs: https://www1.hgst.com/hdd/support/download.htm#DFT (need to build a bootable DOS volume, read the doc)

Thats it!

0

HDTune, the free version can check for HDD health.

2
  • 10
    I don't see any version for Linux on their page.
    – Suzana
    Aug 29, 2014 at 20:52
  • It also stops at an early version (2.55), and does not work on newer and/or larger drives that require 64-bit access like 4TB.
    – Pysis
    Mar 15, 2018 at 14:01
0

If the question is:

Which software will warn me when my drive is about to fail?

The answer is none for most cases. Most drives break in a very short period of time, and neither SMART or any other software catches them on time.

Also even if they report the error, a bad sector data can be unrecoverable.

So the real solution to data lost is backups. I really like Synthing for that, with qsyncthingtray, as it makes perfect clones on all devices on the fly.

0

I provide a nice project for beginner to see the hard disk health:

https://github.com/AnalogJ/scrutiny

using docker one line command:

docker run -it --rm -p 8080:8080 -p 8086:8086 \
  -v `pwd`/scrutiny:/opt/scrutiny/config \
  -v `pwd`/influxdb2:/opt/scrutiny/influxdb \
  -v /run/udev:/run/udev:ro \
  --cap-add SYS_RAWIO \
  --device=/dev/sda \
  --device=/dev/sdb \
  --name scrutiny \
  ghcr.io/analogj/scrutiny:master-omnibus
0

As soon as a drive starts to make suspicious noises like this, it is time to make an immediate backup of the disk, as it is giving you a strong clue that risk of failure is significantly raised.

The ddrescue utility is highly recommended for this task: ddrescue has a command line interface similar to the Linux dd utility but works differently under the hood. It is specifically desiged for data recovery and so will give you the best chance of recovering the most data from a failing drive.

To take an image of the full disk with ddrescue, you can use something like this:

ddrescue /dev/sdx /mnt/large_disk/failing_disk.img

Once you have this image on another disk, you'll be ok to mount it as a loopback device:

# find first unused loop device
losetup -f
# read the partition table 
# make the partitions available
losetup -P /dev/loopX /mnt/large_disk/failing_disk.img
# attempt mount the partition
mount /dev/loopXpY /mnt/tmp

Or you could use dd to copy the image onto a new device:

dd /mnt/large_disk/failing_disk.img /dev/sdx bs=4M status=progress
-7

You are on Linux but you can attach your HDD to a friend's computer running Windows.

You don't need any complicated software to check HDD health. Use Crystal Disk Info for Windows to check if your HDD is in good condition or if there is any damage.

It will also show the S.M.A.R.T data with an indicator beside each value so if you find a red indicator then there is a problem with your hard drive.

2
  • 36
    You do realise there's good linux native SMART software right?
    – Journeyman Geek
    Jun 6, 2012 at 12:25
  • I have also used this utility, and have not found it to surface test the drive / search for bad blocks/sectors, even after looking through its Advanced Functions. While talking about Windows though, and just to throw more terms on to the page that can be quickly searched, I have used MiniTool Partition Wizard Free to surface test. I don't think HDDRegenerator has this feature, and only reads S.M.A.R.T. data like CDI.
    – Pysis
    Mar 15, 2018 at 14:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .