From owner-freebsd-questions@FreeBSD.ORG Sat Jul 21 14:55:17 2012 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id C4D50106564A for ; Sat, 21 Jul 2012 14:55:17 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mx01.qsc.de (mx01.qsc.de [213.148.129.14]) by mx1.freebsd.org (Postfix) with ESMTP id 850968FC0C for ; Sat, 21 Jul 2012 14:55:17 +0000 (UTC) Received: from r56.edvax.de (port-92-195-22-218.dynamic.qsc.de [92.195.22.218]) by mx01.qsc.de (Postfix) with ESMTP id 188E43CF49; Sat, 21 Jul 2012 16:55:15 +0200 (CEST) Received: from r56.edvax.de (localhost [127.0.0.1]) by r56.edvax.de (8.14.5/8.14.5) with SMTP id q6LEtF1K002200; Sat, 21 Jul 2012 16:55:15 +0200 (CEST) (envelope-from freebsd@edvax.de) Date: Sat, 21 Jul 2012 16:55:15 +0200 From: Polytropon To: Leslie Jensen Message-Id: <20120721165515.88e029b1.freebsd@edvax.de> In-Reply-To: <500ABECA.5010404@eskk.nu> References: <500ABECA.5010404@eskk.nu> Organization: EDVAX X-Mailer: Sylpheed 3.1.1 (GTK+ 2.24.5; i386-portbld-freebsd8.2) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: freebsd-questions@freebsd.org Subject: Re: Power failure during portsnap fetch update X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Polytropon List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Jul 2012 14:55:17 -0000 On Sat, 21 Jul 2012 16:38:02 +0200, Leslie Jensen wrote: > > My file system /usr/ports/net go damaged > > I've done fsck -F in single user mode but there are warnings about not > being able to fix this. First of all, you should give fsck a second try. Check the damaged partition per "fsck -y /dev/ad0s1f" (which refers to that partition, e. g. /usr). > The directories below cannot be removed That indicates a major file system defect. > How do I go about this? There is a nice tool in the base system: clri (clear inode). Please note that you're going to "get your hands dirty" with this approach! First, determine the inodes of the "offending" directories. Use "ls -ldi" to do this. Example: # cd /usr/ports/net # ls -ldi ccxstream netselect spread vde2 288794 drwxr-xr-x 3 root wheel 512 2011-08-21 03:14:43 ccxstream/ 331753 drwxr-xr-x 3 root wheel 512 2011-08-21 03:16:10 netselect/ 424004 drwxr-xr-x 3 root wheel 512 2011-08-21 03:17:50 spread/ 424104 drwxr-xr-x 2 root wheel 512 2011-08-21 03:18:04 vde2/ Alternative: You can also use "stat" to obtain information about a file (and a directory) and its "health". Example: # cd /usr/ports/net # stat ccxstream netselect spread vde2 120 288794 drwxr-xr-x 3 root wheel 1139829 512 "Jul 21 16:46:35 2012" "Aug 21 03:14:43 2011" "Aug 21 03:14:43 2011" "Feb 18 02:04:47 2011" 16384 4 0 ccxstream 120 331753 drwxr-xr-x 3 root wheel 1325518 512 "Jul 21 16:46:35 2012" "Aug 21 03:16:10 2011" "Aug 21 03:16:10 2011" "Feb 18 02:04:58 2011" 16384 4 0 netselect 120 424004 drwxr-xr-x 3 root wheel 1696620 512 "Jul 21 16:46:35 2012" "Aug 21 03:17:50 2011" "Aug 21 03:17:50 2011" "Feb 18 02:05:15 2011" 16384 4 0 spread 120 424104 drwxr-xr-x 2 root wheel 1696720 512 "Jul 21 16:46:35 2012" "Aug 21 03:18:04 2011" "Aug 21 03:18:04 2011" "Feb 18 02:05:18 2011" 16384 4 0 vde2 You recognize the inode numbers here. Write down the inode numbers or store them in a temporary file. You can script this process if you like. :-) Then "go out of" the partition and unmount it. You are safer if you apply clri to an UNMOUNTED partition. Then, for example, do this: # clri /dev/ad0s1f 288794 # clri /dev/ad0s1f 331753 # clri /dev/ad0s1f 424004 # clri /dev/ad0s1f 424104 Note that this directly modifies "file system bowels" of the /usr partition! When done, apply fsck again: # fsck -yf /dev/ad0s1f Maybe fsck finds some errors in inode construction and will therefore recover "lost data" (which we will accept as irrelevant at this point) into the lost+found/ root directory on that partition. You can remove its content later on. If fsck finishes with success, you should be able to mount the /usr partition again. Of course, some subdirecories in the ports tree are now missing, but that has been inteneded. Side note: You can use the program "fsdb" to investigate inode information in detail. See "man fsdb" and "man clri" for details. -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...