# Hard Disks with bad sectors



## freethread (Oct 18, 2010)

One of two HD on a FreeBSD system 8.1-RELEASE has bad sectors. The HD are configured as follow:

```
ad0
   /
   /var
   /tmp
   swap
ad1
   /usr
   swap
```
ad1 (/usr) has bad sectors. This problem started about one month ago, the day after I updated from 8.0-RELEASE-p2 to 8.0-RELEASE-p4 then to 8.1-RELEASE. Yesterday I made the patch update of 8.1-RELEASE. All updates were made using freebsd-update with default configuration file. The system notify bad sectors in daily e-mail reports, it never changed from the first notification about one month ago (this is the last one):


```
+++ /tmp/security.UXrgMx73 2010-10-17 03:11:46.000000000 +0200
+ad1: FAILURE - READ_DMA status=51<READY,DSC,ERROR> error=40<UNCORRECTABLE> LBA=11440891
+g_vfs_done():ad1s1d[READ(offset=3710220288, length=2048)]error = 5
+ad1: FAILURE - READ_DMA status=51<READY,DSC,ERROR> error=40<UNCORRECTABLE> LBA=30928447
+g_vfs_done():ad1s1d[READ(offset=13687848960, length=2048)]error = 5
+ad1: FAILURE - READ_DMA status=51<READY,DSC,ERROR> error=40<UNCORRECTABLE> LBA=32058047
+g_vfs_done():ad1s1d[READ(offset=14266204160, length=2048)]error = 5
+ad1: FAILURE - READ_DMA status=51<READY,DSC,ERROR> error=40<UNCORRECTABLE> LBA=32057915
+g_vfs_done():ad1s1d[READ(offset=14266136576, length=2048)]error = 5
+ad1: FAILURE - READ_DMA status=51<READY,DSC,ERROR> error=40<UNCORRECTABLE> LBA=34691499
+g_vfs_done():ad1s1d[READ(offset=15614531584, length=2048)]error = 5
+ad1: FAILURE - READ_DMA status=51<READY,DSC,ERROR> error=40<UNCORRECTABLE> LBA=34691623
+g_vfs_done():ad1s1d[READ(offset=15614595072, length=2048)]error = 5
+ad1: FAILURE - READ_DMA status=51<READY,DSC,ERROR> error=40<UNCORRECTABLE> LBA=11440891
+g_vfs_done():ad1s1d[READ(offset=3710220288, length=2048)]error = 5
+ad1: FAILURE - READ_DMA status=51<READY,DSC,ERROR> error=40<UNCORRECTABLE> LBA=30928447
+g_vfs_done():ad1s1d[READ(offset=13687848960, length=2048)]error = 5
+ad1: FAILURE - READ_DMA status=51<READY,DSC,ERROR> error=40<UNCORRECTABLE> LBA=32058047
+g_vfs_done():ad1s1d[READ(offset=14266204160, length=2048)]error = 5
+ad1: FAILURE - READ_DMA status=51<READY,DSC,ERROR> error=40<UNCORRECTABLE> LBA=32057915
+g_vfs_done():ad1s1d[READ(offset=14266136576, length=2048)]error = 5
+ad1: FAILURE - READ_DMA status=51<READY,DSC,ERROR> error=40<UNCORRECTABLE> LBA=34691499
+g_vfs_done():ad1s1d[READ(offset=15614531584, length=2048)]error = 5
+ad1: FAILURE - READ_DMA status=51<READY,DSC,ERROR> error=40<UNCORRECTABLE> LBA=34691623
+g_vfs_done():ad1s1d[READ(offset=15614595072, length=2048)]error = 5
```

Today the system does not mount /usr and starts in single user mode.

I decided to change the HD with another of the same brand/type Maxtor ATA 80 GB model 6Y080P0. I executed fdisk, changed geometry to right values (16383/16/63) created one partition (all space), then ran label and created two slices: swap 2GB and /usr2 76GB. During newfs formatting some system messages came out, stating bad sectors exists on the new drive and newfs work aborted.

The system is quite old, the new HD was used on a Windows system with a single NTFS partition. I need to start the machine in multi user and modified the fstab to not check the drive (change fields 5th and 6th from 2 to 0) in the hope the system restart in multi user but it does not work. Is there a way to bypass the filesystem check and mount the bad HD?


----------



## vicf (Oct 18, 2010)

Try to clean bad sectors with clri or fsdb. See http://forums.freebsd.org/showthread.php?t=4508


----------



## freethread (Oct 20, 2010)

Thank you for reply, changed HD and now copying files, work in progress.

*@vicf*
I read the forum post you suggested http://forums.freebsd.org/showthread.php?t=4508, it is not a simple task, anyways *sprewell* wrote:



> ...
> What people apparently normally do in this situation is backup all their data and write zeros to the entire partition; this triggers the disk firmware to reallocate the bad sectors, which it can only do on a write to the bad sector, not on a read.
> ...



If I wrote a simple prog that read every block and write it back, the firmware will recognize, and mark, bad sectors (i.e. using bread/bwrite of libufs()) avoiding system notifications (and probably remounting the bad HD)?

Some notes
The second HD I previously prepared with fdisk/bsdlabel has a problem in boot sector, I re-executed fdisk specifying a standard boot manager, the system come out with error messages, disk is not usable and not formattable (cannot post message content, only see the bright white messages but overwritten by sysinstall-fdisk message dialog).
Remounted it on a Windows system, re-fdisked with NTFS partition, it raise the same error during Windows installation, before was used as a secondary HD.
All HDs fdisked in Windows (XP or newer) show a bad CHS geometry. This also happens installing FreeBSD in a virtual machine (Virtual PC). Old HDs used in Windows 98 do not show this warning (tested with 6, 8, 20 GB HDs).


----------



## freethread (Oct 20, 2010)

An update:

Files copied ok. While modifying, copying and deleting files with mc (in single user mode) on the fresh installed HD, many errors like this came out


```
ad2: WARNING - READ_DMA UDMA ICRC error (retying request) LBA=nnnnnn
ad2: FAILURE - READ_DMA status=51<READY,DSC,ERROR> error=84<ICRC,ABORTED> LBA=nnnnnn
```

Ok, all the HDs I used are 'brand new second hand' but these failures are statistically improbable. I did search on the Net the key 'READ_DMA' and found a thread on this forum of june 2009 *READ DMA UDMA ICRC Error attempting to mount root*. It is not strictly related to my problem, but I read something strange in one of *indexofire* replies (the 4th)



> when the system boot, it will use UDMA100 sometimes so it crashed as UDMA100.
> 
> I use the solution right now:
> 1. boot freebsd in Safe Mode
> ...



In 8.1-RELEASE system boot messages, one of it states that *rc.early* is obsolete and will not be processed. Is perhaps my problem related with that? I revert to 8.0-RELEASE (new installation) with new HDs (brand new second hand) and see if the fault persist mounting old HDs.


----------



## freethread (Oct 22, 2010)

Installed 8.0-RELEASE (fresh installation) on a disk where 8.1-RELEASE raised READ_DMA errors and updated with freebsd-update to 8.0-RELEASE-p4 works fine. Currently installing some ports, no errors raised. Mounting the old disk with bad sectors on /mnt works with no errors.

The Kernel is GENERIC, I will make a custom Kernel (vesa + SC_PIXEL_MODE + new colors for system errors) when finished installing ports. It seems my old installation was misconfigured or something changed in 8.1-RELEASE. The strange thing is the old ad0 disk never raised system errors, all the other disks (the old ad1 and other 4 disk used, 3 of them same brand/model) raise errors in 8.1-RELEASE.


----------

