Bad sectors

Hi all,
I’ve HDD with bad sectors, and I’d like to install openSuse.
But, after install, the OS try to write (I think) on these sectors.
How can I do to overide these sectors and don’t try to write on?

Thanks for advance.
Cordialy,
Hayaato

Bad sectors equals “don’t use anymore”. It’s a sign that the disk is in a degrading condition. Yes, it’s possible to allocate bad blocks, but now that you have them, there’s gonna be more. My 2 cents.

This depends on the filesystem in use. For the default ext4 you could run “e2fsck” with the ‘-c’ option. From “man e2fsck”:

       -c     This option causes e2fsck to use badblocks(8) program  to  do  a
              read-only  scan  of  the device in order to find any bad blocks.
              If any bad blocks are found, they are added  to  the  bad  block
              inode  to  prevent them from being allocated to a file or direc-
              tory.  If this option is specified twice,  then  the  bad  block
              scan will be done using a non-destructive read-write test.



But as Knurpht already wrote, it’s probably not advisable to use that disk anymore. At least not for important data! :wink:

So the only solution is I’ve to buy a new HDD?

Thanks, I’ll try this :slight_smile:

Not the only solution, but the only safe one.

See my previous post.
Another option would be to partition the drive in a way that the bad blocks are in unallocated space. But that would be not feasable of course if they are spread across the disk.

Use “smartctl” to get an impression of the state of the drive.

You can run “badblock” to exactly determine the position of all bad blocks on the disk.
Try to use the read-write test if you have no data on the disk. Some (or even all) bad blocks may then be reallocated by the drive’s logic and “disappear”. (see “man badblocks”)

On 2013-09-24 13:06, hayaato wrote:
>
> Hi all,
> I’ve HDD with bad sectors, and I’d like to install openSuse.
> But, after install, the OS try to write (I think) on these sectors.
> How can I do to overide these sectors and don’t try to write on?

Write zeros on the entire disk, with dd:


dd if=/dev/zero of=/dev/sdX

Then run smartctl long test on that disk (see man page for
instructions), and examine the output. There should not be any pending
sector for remapping.

Repeat the entire procedure.

If each time new bad sectors appear, or the smart test warns that the
remap zone is spent, throw the disk away to the garbage.


Cheers / Saludos,

Carlos E. R.
(from 12.3 x86_64 “Dartmouth” at Telcontar)

This topic is one I have a strong opinion on. You can find my thoughts here

On 2013-09-24 15:56, caprus wrote:
>
> This topic is one I have a strong opinion on. You can find my thoughts
> ‘here’ (http://tinyurl.com/oqtlx9b)

Some bad sectors are present from manufacture time. I have seen disks
with some bad sectors since I bought them, or soon after; these are
simply remapped to the area reserved by manufacturers for this very
purpose. I have used these disks for more than 12000 hours after
“discovery” without a single error more.

Some bad sectors originate as you say, from surface degeneration, and
the problem keeps getting worse. This type is dangerous.

Before deciding, you should find out which kind of defect it is. If the
number does not increase, the disk is probably usable.


Cheers / Saludos,

Carlos E. R.
(from 12.3 x86_64 “Dartmouth” at Telcontar)

Thanks a lot!
I started my computer with a live ubuntu and I type this command:
e2fsck -c [my_disk]

It was very long, but it work perfectly now

thanks!!

On 09/24/2013 11:26 AM, hayaato wrote:
>
> Thanks a lot!
> I started my computer with a live ubuntu and I type this command:
> e2fsck -c [my_disk]
>
> It was very long, but it work perfectly now

But it probably will fail. As was stated earlier, once bad sectors start, they
generally get worse. Do not trust that disk drive with data that you do not want
to lose.

You haven’t read @caprus linked post. Backup everything while you still can, you’re walking on thin ice. But, in the end it’s your precious data you’re loosing. Personally I took the risk once -money reasons- , never again.