Utility for Checking and Repairing HDD Bad Sectors?
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Utility for Checking and Repairing HDD Bad Sectors?
I am using openSUSE Leap 42.1, 64-bit, with the KDE desktop environment.
Is there a utility that can be run from a Live CD so that the entire HDD (sda) can be checked and repaired for bad sectors?
I am told that fsck only checks filesystems instead of the whole HDD --and it does no repair job anyhow!
Yes, I realize that I should backup everything and move it to a new HDD, and I will do that. But I am also curious to know whether such utility exists in Linux. (Something similar to MS Windows' CHKDSK)
Fsck checks only filesystems, it is true, but it does also repair errors. However, no software tool can repair truly bad sectors! It may be able to recover data through journalling and other means, but a bad sector is a hardware problem.
For one, CHKDSK cannot check the entire disk, as can be seen by the fact that you give a drive letter, which in all actuality is a reference to a filesystem. Also, there is no reason for fsck or CHKDSK or any other program to even attempt to repair bad sectors, because:
1) It rarely can be done as it is a hardware problem.
2) There is no point in working anywhere outside a filesystem, as there is no data there, and
3) Bad sectors are added to a badblock list anyway and not used.
Fsck checks only filesystems, it is true, but it does also repair errors. However, no software tool can repair truly bad sectors! It may be able to recover data through journalling and other means, but a bad sector is a hardware problem.
For one, CHKDSK cannot check the entire disk, as can be seen by the fact that you give a drive letter, which in all actuality is a reference to a filesystem. Also, there is no reason for fsck or CHKDSK or any other program to even attempt to repair bad sectors, because:
1) It rarely can be done as it is a hardware problem.
2) There is no point in working anywhere outside a filesystem, as there is no data there, and
3) Bad sectors are added to a badblock list anyway and not used.
Okay, so...
1) How does one run fsck on all the filesystems present in sda? Common sense tells me that I have to run it using some sort of Live CD so that sda remains unmounted. But which one?
2) What program adds bad sectors to a badblock list? Fsck, perhaps? I've never run it manually...
I'd run smartctl test on it and look at bad and reallocated sector count. In my experience once those numbers start increasing it is the time for new drive (it is near of its end).
Last edited by Emerson; 11-16-2015 at 05:21 PM.
Reason: Typo.
1. Your root partition will be automatically fsck'ed on boot. If you have the home directory on the root partition, then it is simply a matter of remounting any other partitions read-only and running fsck.
2. The program "badblocks" will check for badblocks and add them to the badblocks list. (Actually, "man badblocks" recommends "fsck -c" instead for block size safety.) However, the hard drive manages the badblock list in the hardware itself, so as to know at a low level where not to write to.
Distribution: Cinnamon Mint 20.1 (Laptop) and 20.2 (Desktop)
Posts: 1,630
Rep:
Quote:
There is no tool that can repair bad blocks on a hard drive.
Bad blocks aren't repaired. There are spare cylinders on every hard disk (cylinder = No. of platters x No. of heads x No. of sectors in one rev of the platters.)
When a bad block is found, usually by some sort of write/read back and verify, if the read back info is different, the sector is marked as bad in the bad block list and a spare sector within the spare cylinders is "vectored" in. I'm not sure if this is automatic on current drives, it wasn't when I was playing with Sun, HP and IBM disks a few years ago.
This means that whenever the sector containing the bad block is addressed, instead of accessing the faulty block, the seek accesses is re-vectored to the replacement sector. (Original sector address + vector address = replacement sector).
I'm not sure what's used in Linux to do this but it would possibly have to be low level, probably with the drive backed up before and restored after.
On Sun systems they had a utility called, er... "format" which allowed you to run a "read/analyse" pass which would re-vector bad blocks. You'd have to boot the Install media (like a live Linux CD) to run it on a drive though, so we're not talking doing this on a live system. You had to run it two or three times in succession to get a clean pass.
At one time Norton had a tool that could change the alignment of the blocks slightly.
What makes a bad block is usually how the initial sector is laid out. That being the low level format. If you can find a low level format you might be able to do the low level and lay down a new initial zero sector and if it moves slightly the bad blocks may end up working. SCSI drives are commonly low level formatted to fix this issue (or hide more accurately).
Now, the problem is you most likely won't get a factory program to manage the drive like that anymore. Bad blocks happen to all drives. The percentage you wish to continue running it is the way you choose. At some point you fix the issue. Either by replacing the drive or what else may cause it.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.