LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Utility for Checking and Repairing HDD Bad Sectors? (https://www.linuxquestions.org/questions/linux-newbie-8/utility-for-checking-and-repairing-hdd-bad-sectors-4175559043/)

tb75252 11-16-2015 03:09 PM

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)

oldtechaa 11-16-2015 03:19 PM

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.

tb75252 11-16-2015 03:33 PM

Quote:

Originally Posted by oldtechaa (Post 5450584)
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...

Emerson 11-16-2015 04:12 PM

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).

oldtechaa 11-16-2015 04:59 PM

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.

Habitual 11-16-2015 05:52 PM

And if it hasn't been said in so many words...
There is no tool that can repair bad blocks on a hard drive.

Soadyheid 11-16-2015 08:02 PM

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.

My :twocents:

Play Bonny!

:hattip:

jefro 11-16-2015 10:28 PM

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.

peterb 11-17-2015 02:19 AM

If you want a separate utility then you might want SpinRite. https://www.grc.com/default.htm


All times are GMT -5. The time now is 12:13 PM.