You might have faced the moment when you copy a file to a storage drive such as a flashdrive and find out that some parts are Corrupted. It’s all because it might be the end of its Life
In this tutorial, I’m going to teach a way to check a storage drive’s health with basic Hash checking with any software of your choice.
For this tutorial, I chose 7Zip.
If you’re a Linux user; you can use the “sha1sum” command in terminal, I will show it in the tutorial.
Every file has a “Cryptographic Hash” which is the signature of that file and the smallest change to that file can change the Hash easily.
So if I have a file and I copy it to a damaged USB flashdrive or an HDD or any kind of storage, that hash should change and my file will not be the original and the content is damaged.
This is an amazing tool which we can use to verify the files we downloaded or even checking a storage drive’s health; Here’s how it’s done:
I have my trustworthy SSD and a huge video file on it which I’m going to copy to a USB flashdrive which is suspected of corrupting every video file I copy to it. It’s better to do this with a huge file to fill out nearly all the sectors in that storage and with this, the test will be more accurate.
First I check the original file’s hash on the SSD which is “09A537258BDF21BD485A415995F1E3322DB3FC66“. This is the original file’s Hash.
I used SHA-1 because of its short length and speed.
And then, I copied the file to the suspicious flash drive and as expected, the Hash was changed to “94C22CC8977720231EA8E8A64CC82A8EBB942F49” which means that the file’s content was changed/damaged.
Now let’s take a look at the video and see how it’s corrupted:
And as expected, some frames were damaged because of the damaged NVM (non-volatile memory) or the controller in the flash drive.
This is why you shouldn’t cheap out on your storage equipment or buying small sized flash drives, because some have bad memory controllers or low quality NVMs inside them which will ruin all of your data.
Here’s how Hash checking is done in Linux:
We first find our file, then give the highest priority which is 20 to the “sha1sum” command with “nice” to make the process faster,
The original file:
The damaged file on the flashdrive:
I know! the file’s hash changed after rebooting to Ubuntu because the FlashDrive is so damaged. I bet even more frames are corrupted.
so now that we know that the flashdrive is damaged then how to fix it? We can use any repairing software we want to replace the damaged sectors. I found the “Data Lifeguard Diagnostic” from Western Digital (link)to be the simple tool for this subject, it checks all the sectors and replaces them with ease. Notice that the process can take hours.