From owner-freebsd-current@FreeBSD.ORG Sun Mar 14 09:55:25 2010 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1A453106564A for ; Sun, 14 Mar 2010 09:55:25 +0000 (UTC) (envelope-from 000.fbsd@quip.cz) Received: from elsa.codelab.cz (elsa.codelab.cz [94.124.105.4]) by mx1.freebsd.org (Postfix) with ESMTP id B7C1C8FC13 for ; Sun, 14 Mar 2010 09:55:24 +0000 (UTC) Received: from elsa.codelab.cz (localhost.codelab.cz [127.0.0.1]) by elsa.codelab.cz (Postfix) with ESMTP id C49E119E023; Sun, 14 Mar 2010 10:55:22 +0100 (CET) Received: from [192.168.1.2] (r5bb235.net.upc.cz [86.49.61.235]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by elsa.codelab.cz (Postfix) with ESMTPSA id 0DBB519E019; Sun, 14 Mar 2010 10:55:20 +0100 (CET) Message-ID: <4B9CB287.9080205@quip.cz> Date: Sun, 14 Mar 2010 10:55:19 +0100 From: Miroslav Lachman <000.fbsd@quip.cz> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.9.1.8) Gecko/20100205 SeaMonkey/2.0.3 MIME-Version: 1.0 To: =?UTF-8?B?RGFnLUVybGluZyBTbcO4cmdyYXY=?= References: <20100308102918.GA5485@localhost> <4B94DDC8.5080008@quip.cz> <20100308115052.GA31896@office.redwerk.com> <4B94FBA6.5090107@quip.cz> <861vfq995i.fsf@ds4.des.no> <4B9BF957.4060507@quip.cz> <86eijn3of2.fsf@ds4.des.no> In-Reply-To: <86eijn3of2.fsf@ds4.des.no> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Cc: freebsd-current@freebsd.org Subject: Re: A tool for remapping bad sectors in CURRENT? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Mar 2010 09:55:25 -0000 Dag-Erling Smørgrav wrote: > Miroslav Lachman<000.fbsd@quip.cz> writes: >> So... can somebody with enough knowledge write some docs / script how >> to find the affected file based on LBA read error from messages / >> SMART log? > > ZFS will tell you straight away, but I guess if you used ZFS, you > wouldn't be asking :) Yes, but we have ZFS only on two servers, others are using UFS2 (some with gmirror, some with gjournal) > For FFS, you can unmount the file system (boot from a CD or memory stick > or whatever if that file system is / or /usr), run fsdb on the failing > disk, use findblk to look up the inode number for the file that contains > the bad sector. Note that you have to convert the LBA to an offset > relative to the start of the partition. As I write in my first post to this thread, I already tried fsdb + findblk, but without success. Findblk did not returned any inode. Maybe the meaning of block is of different size or something else I can't understand. So can you please show me some real world example? I have one from the past: __________________ /var/log/messages: Sep 23 23:58:00 edith kernel: ad4: FAILURE - READ_DMA status=51 error=40 LBA=79725056 Sep 23 23:58:00 edith kernel: GEOM_MIRROR: Request failed (error=5). ad4[READ(offset=40819228672, length=131072)] __________________ SMART log: After command completion occurred, registers were: ER ST SC SN CL CH DH -- -- -- -- -- -- -- 40 51 00 6f 82 c0 44 Error: UNC at LBA = 0x04c0826f = 79725167 The LBA of bad sector is *79725167* __________________ Information about disk slices: sysid 165 (0xa5),(FreeBSD/NetBSD/386BSD) start 63, size 209712447 (102398 Meg), flag 80 (active) beg: cyl 0/ head 1/ sector 1; end: cyl 1023/ head 254/ sector 63 The data for partition 2 is: sysid 165 (0xa5),(FreeBSD/NetBSD/386BSD) start 209712510, size 1743807555 (851468 Meg), flag 0 beg: cyl 1023/ head 255/ sector 63; end: cyl 1023/ head 254/ sector 63 __________________ According to LBA and size of s1, I thing the error is in s1 # /dev/mirror/gm0s1: 8 partitions: # size offset fstype [fsize bsize bps/cpg] a: 2097152 0 / b: 25165824 2097152 swap c: 209712447 0 d: 12582912 27262976 /var e: 146800640 39845888 /var/db f: 16777216 186646528 /usr g: 6288703 203423744 /tmp And LBA 79725056 is on */var/db* (between offset 39845888 and 186646528) __________________ s1 starts 63 sectors from the beginning of the drive and /var/db has offset 39845888. So am I right that I need to find block number *39879105* by findblk command? LBA err - s1 start - /var/db offset = findblk inside /dev/mirror/gm0s1e 79725056 - 63 - 39845888 = 39879105 __________________ /# fsdb -r /dev/mirror/gm0s1e ** /dev/mirror/gm0s1e (NO WRITE) Examining file system '/dev/mirror/gm0s1e' Last Mounted on /var/db current inode: directory I=2 MODE=40755 SIZE=512 BTIME=May 1 08:07:23 2009 [0 nsec] MTIME=Sep 24 15:52:01 2009 [0 nsec] CTIME=Sep 24 15:52:01 2009 [0 nsec] ATIME=Sep 24 16:24:34 2009 [0 nsec] OWNER=root GRP=wheel LINKCNT=11 FLAGS=0 BLKCNT=4 GEN=4ebc65fc findblk 39879105 findblk 39879106 findblk 39879107 findblk 39879108 . . I tried more than 256 incrementing block numbers, but findblk didn't found any inode! (length=131072 in error message means 256 sectors, right?) So there must be some misunderstanding on my part and that's why I am asking for some step-by-step documentation or script "how to find file by LBA read error message" I tried the fsdb + findblk on well known data, but again without success. I created file /tmp/test.txt, it has inum 3, than I use fsdb on gm0s1f (gm0s1f is mounted as /tmp). Command "inode 3" inside fsdb prompt returned informations about this file, command "blocks" returned 3001 as block number, but command "findblk 3001" returned nothing instead of inum 3! Where is the error? What I am doing wrong? __________________ ~/# echo test > /tmp/test.txt ~/# ls -i /tmp/test.txt 3 /tmp/test.txt ~/# fsdb -r /dev/mirror/gm0s1f ** /dev/mirror/gm0s1f (NO WRITE) Examining file system '/dev/mirror/gm0s1f' Last Mounted on /tmp current inode: directory I=2 MODE=41777 SIZE=512 BTIME=Feb 7 18:32:22 2008 [0 nsec] MTIME=Mar 14 10:33:22 2010 [0 nsec] CTIME=Mar 14 10:33:22 2010 [0 nsec] ATIME=Mar 14 10:33:35 2010 [0 nsec] OWNER=root GRP=wheel LINKCNT=7 FLAGS=0 BLKCNT=4 GEN=3f7c9384 fsdb (inum: 2)> inode 3 current inode: regular file I=3 MODE=100644 SIZE=5 BTIME=Mar 14 10:33:22 2010 [0 nsec] MTIME=Mar 14 10:33:22 2010 [0 nsec] CTIME=Mar 14 10:33:22 2010 [0 nsec] ATIME=Mar 14 10:33:22 2010 [0 nsec] OWNER=root GRP=wheel LINKCNT=1 FLAGS=0 BLKCNT=4 GEN=45c26de1 fsdb (inum: 3)> blocks Blocks for inode 3: Direct blocks: 3001 (1 frag) fsdb (inum: 3)> findblk 3001 fsdb (inum: 3)> ^^^^^^^^ findblk did not returned inode 3! > Unfortunately, you can't easily go from inode to file name; you have to > mount the file system and use something like find -inum. Yes, I know this. Thanks in advance to help me understand and use fsdb + findblk commands. Miroslav Lachman PS: all above was tested on gmirror gm0, but I did the same tests on single drive ad4 with the same "empty" result (info just for case if fsdb can't be used on gmirror, but I don't think so)