LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 01-25-2012, 11:45 AM   #1
Clarence-Adams
Member
 
Registered: Nov 2011
Distribution: Archlinux
Posts: 31

Rep: Reputation: Disabled
Fixing Bad Sectors


Windows 7 has a utility that scans hard drives and automatically repairs/relocates bad sectors. I did a long test on a hard drive and it says that it has bad sectors. I tried formatting it to ex2 and using "e2fsck -fpC 0 /dev/sdb" but it said that the hard drive was fine and fixed nothing.

How do I automatically scan a hard drive for errors and fix them in Linux?
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 01-25-2012, 11:58 AM   #2
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE 42.1_64+Tumbleweed-KDE, Mint 17.3
Posts: 4,023

Rep: Reputation: Disabled
That is usually done automatically during boot. You can tell the bootloader to display the early messages to be able to check on it during booting, though I don't know how it is done in GRUB2 Ubuntu is using.

You can set the checking interval with the "tune2fs" command (e.g. every 60 days or after 50 boots, whichever comes first, and so on). I suggest "man tune2fs" to check on the options.

Last edited by JZL240I-U; 01-25-2012 at 11:59 AM.
 
Old 01-25-2012, 12:09 PM   #3
Clarence-Adams
Member
 
Registered: Nov 2011
Distribution: Archlinux
Posts: 31

Original Poster
Rep: Reputation: Disabled
Well I'm using it for another purpose. I'm testing hard drives so that I can sell them, not for personal use. I want to know if there is a scan that I can do one time for one hard drive to fix the bad sectors, switch out another hard drive and repeat the process.
 
Old 01-25-2012, 12:22 PM   #4
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE 42.1_64+Tumbleweed-KDE, Mint 17.3
Posts: 4,023

Rep: Reputation: Disabled
Well I think so. (The drive in question must be umounted!). Run the "e2fsck -f", the "-f" option will force the check. Is that what you are looking for?
 
Old 01-25-2012, 01:10 PM   #5
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,133
Blog Entries: 2

Rep: Reputation: 4836Reputation: 4836Reputation: 4836Reputation: 4836Reputation: 4836Reputation: 4836Reputation: 4836Reputation: 4836Reputation: 4836Reputation: 4836Reputation: 4836
If a disk scan utility reports bad sectors that have to be reallocated by software, not by the disk itself, that means that the disk already ran out of its spare sectors to do that itself. That is for almost 100% a sign that the particular disk is dying.
I would not consider to sell such a disk, and I would be really angry if someone is trying to sell me something like this as working part. I personally would even consider that to be fraudulent behavior.

By the way, there is no way to fix bad sectors, what the disk utility in Windows actually does is marking those sectors so that the file system doesn't use them. If you format it again the bad sectors will be back again (in fact, they never were gone, just not used).

@JZL240I-U: I think you misunderstood that. The OP is not asking to fix file-system errors, but physical bad sectors on the disk, which can't be fixed.
 
1 members found this post helpful.
Old 01-25-2012, 01:11 PM   #6
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 8,151
Blog Entries: 4

Rep: Reputation: 2717Reputation: 2717Reputation: 2717Reputation: 2717Reputation: 2717Reputation: 2717Reputation: 2717Reputation: 2717Reputation: 2717Reputation: 2717Reputation: 2717
If you have any bad sectors on the drive ... buy a new one immediately.
 
Old 01-25-2012, 03:30 PM   #7
Clarence-Adams
Member
 
Registered: Nov 2011
Distribution: Archlinux
Posts: 31

Original Poster
Rep: Reputation: Disabled
Are there any utilities that marks the sectors then? To be honest, my clientele are not the type of people who are worried about quality. I do have clientele that are worried about quality, so I sell them quality product, but the other class of customers are well informed that these are refurbished products.
 
Old 01-25-2012, 03:47 PM   #8
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,133
Blog Entries: 2

Rep: Reputation: 4836Reputation: 4836Reputation: 4836Reputation: 4836Reputation: 4836Reputation: 4836Reputation: 4836Reputation: 4836Reputation: 4836Reputation: 4836Reputation: 4836
Quote:
Originally Posted by Clarence-Adams View Post
Are there any utilities that marks the sectors then?
Marking the sectors will be useless. They get unmarked every time the disk is formatted. Even worse, the will become more over time, destroying data saved in a formerly good sector.

Quote:
that these are refurbished products
No, they are not. Refurbished products are products that are well tested and have passed the tests. You know that your drives are faulty and sell them nonetheless. That has nothing to do with refurbishing.
 
Old 01-25-2012, 04:48 PM   #9
Clarence-Adams
Member
 
Registered: Nov 2011
Distribution: Archlinux
Posts: 31

Original Poster
Rep: Reputation: Disabled
The whole point of this thread was to figure out how to refurbish the product...
 
Old 01-25-2012, 04:59 PM   #10
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,133
Blog Entries: 2

Rep: Reputation: 4836Reputation: 4836Reputation: 4836Reputation: 4836Reputation: 4836Reputation: 4836Reputation: 4836Reputation: 4836Reputation: 4836Reputation: 4836Reputation: 4836
Simple answer: You can't. Those drives are dying.
 
Old 01-25-2012, 05:30 PM   #11
Clarence-Adams
Member
 
Registered: Nov 2011
Distribution: Archlinux
Posts: 31

Original Poster
Rep: Reputation: Disabled
Thank you for your answer. I will not be selling those drives since I have no way of refurbishing them then. I may switch to Windows 7 because of a program called spinrite.
 
Old 01-25-2012, 05:42 PM   #12
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,459

Rep: Reputation: 2064Reputation: 2064Reputation: 2064Reputation: 2064Reputation: 2064Reputation: 2064Reputation: 2064Reputation: 2064Reputation: 2064Reputation: 2064Reputation: 2064
Quote:
Originally Posted by Clarence-Adams View Post
I may switch to Windows 7 because of a program called spinrite.
I don't think you're understanding what they're saying. No matter what OS you use, no matter what software you use, no matter how much "fixing" you do to a drive with bad sectors...the drive is trash. As soon as a drive starts to lose sectors, it goes downhill FAST, and will be inoperable in a very short amount of time. It doesn't matter if you "fix" the bad sectors with any piece of software. Within days/weeks you will get more bad sectors, then more and more, and it will spiral out of control until the drive is toast, usually within a matter of months.

I don't see what you plan to gain with that software. And anyways, you can run it from a bootable CD, you don't need Windows.
 
Old 01-25-2012, 10:34 PM   #13
Clarence-Adams
Member
 
Registered: Nov 2011
Distribution: Archlinux
Posts: 31

Original Poster
Rep: Reputation: Disabled
A lot of other local shops have sworn by the spinrite program and we've had lengthy discussions about it. The success rate is pretty high and the return rate by customers is nonexistent. Thanks for the bootable CD advice. I know you all may be right and I may be wrong, but I'm going to have to try this out for myself and do some experiments. I mean, they must have made the spinrite software for a reason, right? Thanks for the advice and the opposing opinions though, it's always good to hear others opinions so that you may make more informed decisions. I wanted to know if there was a way to repair bad sectors on a hard drive through the Linux OS and I got my answer, plus a lot of other helpful bits of information. Once again, thanks everybody.
 
Old 01-25-2012, 11:27 PM   #14
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 372Reputation: 372Reputation: 372Reputation: 372
Hi Clarence-Adams,

I realize by your last post that you'd prefer to make a graceful exit from this thread. I'd just like to make a few points that may not have been explicitly stated by the other replies.

First: I don't think your thread question is as precise as you would have liked. Specifically, you can't "fix" bad sectors with a piece of software. To actually repair a bad sector on a hard drive, you would need to replace the platter where the failed sector resides--physically opening the drive. Of course, ripping out the platter with the bad sector would mean you ripped out all the other good sectors on that platter--and their data along with them. If you've ever opened up an actual drive before, you know how tightly packed those platters are. Given that physical damage to a platter can make the data in the affected areas unreadable, replacing platters is not practical. In addition to that, replacing the platter may not fix the cause of the problem. It may be that the read/write heads are contacting the platter because of some mechanical component that's failing.

Second: Understand that spinrite does not fix bad sectors for all the reasons I mentioned above. The spinrite software does two things: (1) write testing and (2) filesystem modification. If the write testing gives bad results, the filesystem is modified to add the sector to the "do not use" sector list. That's all. It's the hard drive equivalent of:
Quote:
Patient: Doc, it hurts when I do this
Doc: Then don't do that anymore
So, if by "fix" you meant this type of behavior, then yes, there should be plenty of tools for Linux that do this. I believe fsck can mark bad sectors, but as stated in an earlier reply, any purchaser of the drive that performs a filesystem change/format will lose that "do not use" sector list unless they too run a surface check for bad sectors when they make the change.

I don't want to come off as bad-mouthing spinrite. It may have some very sophisticated testing techniques, but it cannot repair bad sectors. If you believe in the spinrite's website because the author is touted as a computer engineer and computer scientist, then trust me too: I am a computer engineer and I worked at HP/Compaq in their SCSI-RAID product development team (part of the SmartArray line). I personally wrote testing software for our new prototype boards that did everything the spinrite website claims their software does. We had to determine whether testing failures in the prototype were logic failures in the new design or physical failures of the drive(s) or host machine in our Device Under Test. That software wrote each and every sector of every drive multiple times with various data patterns. That data pattern would be something like walking 1's, walking 0's, all 1's, all 0's, or random data. Then each sector was read back and verified after making sure there would be no cache-hits for the drives.

I can personally guarantee you, there was no binary data set that could be written to a sector that would repair any sector that had gone bad. And there's nothing spinrite can do with the drive other than read and write data.

Like I said, spinrite may be some great software, but make sure that you understand what it does for you: analysis--not repair.

Last edited by Dark_Helmet; 01-25-2012 at 11:41 PM.
 
3 members found this post helpful.
  


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
re-allocated sectors count shows 2 bad sectors, in Ubuntu 10.04 disk utility james2b Linux - Hardware 4 10-12-2010 11:16 PM
does it mean bad sectors? thehungrycoder Linux - Hardware 3 10-19-2009 05:52 AM
Smartmontools, fixing Unreadable Disk Sectors justinian0 Linux - Hardware 1 08-08-2009 05:22 AM
fixing bad blocks/sectors warheros Linux - Software 3 07-19-2003 10:01 PM
Bad sectors blystovski Linux - Software 1 10-17-2001 12:18 PM


All times are GMT -5. The time now is 08:51 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration