LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 11-16-2015, 03:09 PM   #1
tb75252
Member
 
Registered: Oct 2010
Posts: 167

Rep: Reputation: Disabled
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)
 
Old 11-16-2015, 03:19 PM   #2
oldtechaa
Member
 
Registered: May 2015
Location: US
Distribution: Fedora
Posts: 364

Rep: Reputation: 83
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.
 
Old 11-16-2015, 03:33 PM   #3
tb75252
Member
 
Registered: Oct 2010
Posts: 167

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by oldtechaa View Post
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...
 
Old 11-16-2015, 04:12 PM   #4
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,513

Rep: Reputation: Disabled
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.
 
Old 11-16-2015, 04:59 PM   #5
oldtechaa
Member
 
Registered: May 2015
Location: US
Distribution: Fedora
Posts: 364

Rep: Reputation: 83
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.
 
Old 11-16-2015, 05:52 PM   #6
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
And if it hasn't been said in so many words...
There is no tool that can repair bad blocks on a hard drive.
 
Old 11-16-2015, 08:02 PM   #7
Soadyheid
Senior Member
 
Registered: Aug 2010
Location: Near Edinburgh, Scotland
Distribution: Cinnamon Mint 20.1 (Laptop) and 20.2 (Desktop)
Posts: 1,630

Rep: Reputation: 470Reputation: 470Reputation: 470Reputation: 470Reputation: 470
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

Play Bonny!

 
Old 11-16-2015, 10:28 PM   #8
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,644

Rep: Reputation: 3551Reputation: 3551Reputation: 3551Reputation: 3551Reputation: 3551Reputation: 3551Reputation: 3551Reputation: 3551Reputation: 3551Reputation: 3551Reputation: 3551
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.

Last edited by jefro; 11-17-2015 at 04:54 PM.
 
Old 11-17-2015, 02:19 AM   #9
peterb
Member
 
Registered: Aug 2003
Location: Athens, Greece
Distribution: Debian, Mandriva, Fedora
Posts: 130

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Question About Repairing Bad Sectors SHENGTON Linux - Newbie 5 05-26-2011 07:33 PM
A linux utility to dump HDD sectors to console. stf92 Linux - Software 5 12-11-2010 04:08 PM
re-allocated sectors count shows 2 bad sectors, in Ubuntu 10.04 disk utility james2b Linux - Hardware 4 10-12-2010 11:16 PM
[SOLVED] Bad Sectors In HDD Israfel2000 Linux - Hardware 17 02-08-2010 07:26 PM
Checking for Bad sectors rotty Linux - Hardware 2 09-28-2006 11:34 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:47 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration