# panic: ffs_blkfree



## a129878 (Apr 8, 2010)

I have my first panic attack and I do not know what to do.

I am sure I have a HDD sector problem as it always fails on the same LBA, as seen on the console in bright font, which must be saying something!
After about 10 retries I get

```
panic: ffs_blkfree
```

OK - I remembered from a 103 years ago that fsck is the guy to use.
Boot up into single user, and after fsck'ing down the /dev/ad4s1.... list I find /usr is in trouble.
fsck asks to update, even though I am getting the LBA complaint on the console, but it never seems to get over the problem.

What do I do now?

FreeBSD 8.0-RELEASE #0: Sat Nov 21 15:48:17 on a simple cheap PC.


----------



## SirDice (Apr 8, 2010)

Replace the harddrive.


----------



## a129878 (Apr 9, 2010)

Bad Bad SirDice.  -20 points.
A few bad sectors should not wipe out a .5G hard drive, especially when it is just one constant sector.
You have been told this before from looking the in archives!
Now I am getting to know my way round this site I find:-
http://forums.freebsd.org/showthread.php?t=4508&highlight=bad+sector.


----------



## a129878 (Apr 9, 2010)

Moderators (DDeamon) could now close this as it contains a reference to a work around / solution.


----------



## DutchDaemon (Apr 9, 2010)

Good thing you told me, otherwise I'd be panicking.


----------



## Carpetsmoker (Apr 18, 2010)

> A few bad sectors should not wipe out a .5G hard drive, especially when it is just one constant sector.



If the bad sector is in a "inconvenient" place then this could serious cause problems, think of the superblock or disklabel. There are backups of those, but manual fiddling may be required to get your data back.
Most hard drives can reallocate sectors, but the data on the original sector is still lost.

I would replace the hard drive even if it has just one bad/reallocated sector ...


----------



## sub_mesa (Apr 19, 2010)

`smartctl -a /dev/<drive>`

Check for "Current Pending Sector" raw value; this should be ZERO. If it is not; you have an unmapped/unrepaired bad sector that can create lots of trouble.

To fix it either use commercial utilities like Spinrite which can fix the damage, or overwrite just that one sector with zeroes; causing the HDD to swap the bad sector and never use it anymore. This will result in 512 bytes of corruption though, and wouldn't be my first choice if this concerns important data. However, this should solve the problems after a fsck.


----------



## jb_fvwm2 (Apr 19, 2010)

If one has a hard drive with "greater than 0" 
Reallocated_Sector_Count, one can /mnt it somewhere
after copying data off to a new drive, and use
it ("use the drive up") as a WRKDIRPREFIX storage medium.
So the drive still should be valuable, vs most uses in
other operating systems.  (Unclear if it applies in this case).
...
The above would not be true if the drive throws "bold text"
errors on tty0 during builds though.
...


----------



## danbi (Apr 29, 2010)

Best solution is of course to replace the drive.

If you need to "save" the drive, try this:
- copy all data from the failed drive to another drive / network server.
- overwrite the entire drive with a command like this
`# dd if=/dev/zero of=/dev/adX bs=1m`
- restore your data back

This should force the drive to remap any bad sectors. This is what most vendor/commercial products that "low level format" drives do anyway.

It is good idea to do full SMART scan, for example with sysutils/smartmontools like this
`# smartctl -t long /dev/adX`
inspect progress/result with
`# smartctl -a /dev/adX`

If the bad sector is not currently used by anything, you may be able to fix things without copying your data off-drive, just with
`# cd /path-to-filesystem-on-drive
# dd if=/dev/zero of=zero bs=1m
# rm zero`

Backup your data.


----------



## Carpetsmoker (Apr 29, 2010)

> It is good idea to do full SMART scan, for example with sysutils/smartmontools like this
> # smartctl -t long /dev/adX
> inspect progress/result with
> # smartctl -a /dev/adX



SMART scans are fairly useless, (SMART attributes and log are not though). Use a proper disk surface scan such as MHDD to test your drive.


----------

