Thanks for your responses!
fsdb really works.
The event sequence was as follows:
$sudo smartctl -t long /dev/ad6
$sudo smartctl -l selftest /dev/ad6

Num  Test_Description    Status                  Remaining  ...
LBA_of_first_error
# 1  Extended offline    Completed: read failure    90%    7376   ...
4007967
<SKIP>
$sudo bsdlabel ad6s1
8 partitions:
#        size   offset    fstype   [fsize bsize bps/cpg]
  a:  1048576        0    4.2BSD     2048 16384     8
  b:  1048576  1048576      swap
  c: 100663227        0    unused        0     0         # "raw" part, don't
edit
  d:  2097152  2097152    4.2BSD     2048 16384 28552
  e:   655360  4194304    4.2BSD     2048 16384 40968
  f: 37748736  4849664    4.2BSD     2048 16384 28552
  g: 58064827 42598400    4.2BSD     2048 16384 28552

>From the above output one can conclude that bad sector
(LBA_of_first_error=4007967) lies in
the partition ad6s1d, which in my case is mounted to /var (from fstab)
Further:
$fsdb -r /dev/ad6s1d

Bad sector offset within /var is
LBA_of_first_error-62-offset_of_partition_d=
4007967-63-2097152=1910752
so, next step:

fsdb (inum: 2)> findblk 1910752
1910752: data block of inode 117934
fsdb (inum: 117934)> inode 117934
current inode: regular file
I=117934 MODE=100644 SIZE=53609
        BTIME=Jul  1 20:10:54 2010 [0 nsec]
        MTIME=Jul  1 20:10:54 2010 [0 nsec]
        CTIME=Jul  1 20:10:54 2010 [0 nsec]
        ATIME=Jul 10 00:33:55 2010 [0 nsec]
OWNER=root GRP=wheel LINKCNT=1 FLAGS=0 BLKCNT=6c GEN=8c5ac7e
fsdb (inum: 117934)>blocks
Blocks for inode 117934:
Direct blocks:
477680, 477688, 477696, 477848 (3 frags)
First fragment FSBlock (477688) when multiplied by 4
gives me exactly 1910752. i.e. LBA_of_first_error
(4 is fsbtodb param from the output of ffsinfo  -l 1 /dev/ad6s1d)

Next I search for defect file:

$ sudo find /var -inum 117934
/var/db/pkg/kdeutils-3.5.10_5/+CONTENTS

And what's more:
when I try to upgrade some port or simply issue the command

$sudo pkgdb -uF

I get this error:

Input/Output error - /var/db/pkg/kdeutils-3.5.10_5/+CONTENTS

wich corresponds exactly with what was previousely
discovered by means of "smartctl", "fsdb" and "find".
Just one more question (maybe a bit stupid): if I try to remap bad sector(s)
in /var/db/pkg with, for instance,

dd if=/dev/zero of=/dev/ad6 bs=512 count=1 seek=1910752

can I cosequently safely restore pkgdb with pkgdb -uF?
TIA

С уважением, Дмитрий
Best regards, Dmitry
email: eingorn...@gmail.com
_______________________________________________
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"

Reply via email to