From owner-freebsd-questions@FreeBSD.ORG Tue Aug 21 01:40:10 2007 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4D0DD16A417 for ; Tue, 21 Aug 2007 01:40:10 +0000 (UTC) (envelope-from cpghost@cordula.ws) Received: from fw.farid-hajji.net (fw.farid-hajji.net [213.146.115.42]) by mx1.freebsd.org (Postfix) with ESMTP id 2AE4C13C48A for ; Tue, 21 Aug 2007 01:40:08 +0000 (UTC) (envelope-from cpghost@cordula.ws) Received: from epia-2.farid-hajji.net (epia-2 [192.168.254.11]) by fw.farid-hajji.net (Postfix) with ESMTP id 23B57DA85A; Tue, 21 Aug 2007 03:42:28 +0200 (CEST) Date: Tue, 21 Aug 2007 03:43:10 +0200 From: cpghost To: Wojciech Puchar Message-ID: <20070821014310.GA3756@epia-2.farid-hajji.net> References: <20070821010406.W61947@wojtek.tensor.gdynia.pl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20070821010406.W61947@wojtek.tensor.gdynia.pl> User-Agent: Mutt/1.5.16 (2007-06-09) Cc: freebsd-questions@freebsd.org Subject: Block to i-node to file name (was Re: uncorrectable disk error) X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Aug 2007 01:40:10 -0000 On Tue, Aug 21, 2007 at 01:04:38AM +0200, Wojciech Puchar wrote: > ad4: FAILURE - READ_DMA48 status=51 > error=40 LBA=465628608 > g_vfs_done():ad4a[READ(offset=238401650688, length=638976)]error = 5 > > how can i find (UFS2) what file uses that block? [I took the liberty to change the subject for better archival] Unless you're an fs guru or very patient and careful, you probably won't or would have a hard time. But don't give up yet! Try the following procedure: 1. Determine the slice where the block is located (fdisk) 2. Determine the partition of the block (bsdlabel) 3. Calculate the partition-relative offset of the block (i.e. subtract the slice offset and subtract from the result the partition offset). 4. Fire up fsdb(8) with the -r option on that file system. 5. Use fsdb's "findblk" command with that fs-relative offset to determine the inode that is holding this block. From "man fsdb": findblk disk block number ... Find the inode(s) owning the specified disk block(s) number(s). Note that these are not absolute disk blocks numbers, but offsets from the start of the partition. Keep in mind that the block could also be in the free list (unused); but you'd not get this error message if it was (?). 6. Verify that the resulting i-node number is the right one by jumping to that inode with the "inode" command of fsdb, and rechecking that this block is indeed held by this i-node with the "blocks" command of fsdb. (you may want to run fsdb in a script(1), to capture the potentially long list of blocks). 7. The inode number you get won't tell you the name of the file. To find this, scan all directories of that file system for this inode number (I'd write a small C proggy for that, but you could just as well use find(1)'s -inum switch. If your disk is dying, this can (wether with a C program or with find(1) crash your system. If the number of directories is not very high, you could try to use fsdb(8) for that. BEWARE: Always use fsdb(8) with the read-only flag -r! You could irrevocably damage your file system otherwise if you don't know exactly what you're doing. Good luck! Regards, -cpghost. P.S.: We really need a little LBA to i-node utility for UFS/UFS2, that we could combine with find /fs -inum ...! If possible, a utility that also takes care of GEOM-ified disks etc... -- Cordula's Web. http://www.cordula.ws/