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!
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.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
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.
Distribution: openSuSE 42.1_64+Tumbleweed-KDE, Mint 17.3
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.
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.
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.
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.
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.
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.
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.
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.
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:
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-26-2012 at 12:41 AM.