From owner-freebsd-hackers@FreeBSD.ORG Mon Sep 24 23:56:18 2007 Return-Path: Delivered-To: freebsd-hackers@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 622AE16A419 for ; Mon, 24 Sep 2007 23:56:18 +0000 (UTC) (envelope-from truckman@FreeBSD.org) Received: from gw.catspoiler.org (adsl-75-1-14-242.dsl.scrm01.sbcglobal.net [75.1.14.242]) by mx1.freebsd.org (Postfix) with ESMTP id 1101313C45B for ; Mon, 24 Sep 2007 23:56:17 +0000 (UTC) (envelope-from truckman@FreeBSD.org) Received: from FreeBSD.org (mousie.catspoiler.org [192.168.101.2]) by gw.catspoiler.org (8.13.3/8.13.3) with ESMTP id l8ONU0IT008004; Mon, 24 Sep 2007 16:30:04 -0700 (PDT) (envelope-from truckman@FreeBSD.org) Message-Id: <200709242330.l8ONU0IT008004@gw.catspoiler.org> Date: Mon, 24 Sep 2007 16:30:00 -0700 (PDT) From: Don Lewis To: samflanker@gmail.com In-Reply-To: <46F7CCF8.5010402@gmail.com> MIME-Version: 1.0 Content-Type: TEXT/plain; charset=us-ascii Cc: freebsd-hackers@FreeBSD.org Subject: Re: fsck of large volume with small memory X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Sep 2007 23:56:18 -0000 On 24 Sep, sam wrote: > hi, all > http://lists.freebsd.org/pipermail/freebsd-questions/2007-June/151686.html > > my problem > # fsck /dev/aacd0s1f > ** /dev/aacd0s1f (NO WRITE) > ** Last Mounted on /usr > ** Phase 1 - Check Blocks and Sizes > fsck_ufs: cannot alloc 2378019004 bytes for inoinfo I'd be willing to bet that one of the cylinder group blocks in your file system got corrupted. > any solutions ? The patch below should allow a manual fsck to run to completion. I'd recommend running "fsck -N" and capturing its output. Then use the clri command (either standalone or in fsdb) to zero out the uninitialized inodes that are unmasked by setting cg_initediblk to its maximum possible value based on the file system parameters. Expect major file system lossage ... I think this patch could be better, but this should get you going ... Index: sbin/fsck_ffs/pass1.c =================================================================== RCS file: /home/ncvs/src/sbin/fsck_ffs/pass1.c,v retrieving revision 1.43 diff -u -r1.43 pass1.c --- sbin/fsck_ffs/pass1.c 8 Oct 2004 20:44:47 -0000 1.43 +++ sbin/fsck_ffs/pass1.c 24 Sep 2007 23:15:22 -0000 @@ -93,9 +93,29 @@ inumber = c * sblock.fs_ipg; setinodebuf(inumber); getblk(&cgblk, cgtod(&sblock, c), sblock.fs_cgsize); - if (sblock.fs_magic == FS_UFS2_MAGIC) + if (sblock.fs_magic == FS_UFS2_MAGIC) { inosused = cgrp.cg_initediblk; - else + if (inosused < 0 || inosused > sblock.fs_ipg) { + pfatal("CG %d: PREPOSTEROUS NUMBER OF INODES %d (cg_initediblk), ASSUMING %d (fs_ipg)\n", + c, inosused, sblock.fs_ipg); + /* + * The cylinder group block is most likely + * totally corrupted and will probably + * fail the magic number check below as well. + * Ignoring cg_initediblk and setting + * inosused to sblock.fs_ipg will allow + * a manual fsck to proceed further instead + * of dying when it attempts to allocate + * an insane amount of memory to store + * the inode info for this cylinder group. + * This may provide enough information + * to allow the system administrator to + * do a better job of patching the + * filesystem with fsdb. + */ + inosused = sblock.fs_ipg; + } + } else inosused = sblock.fs_ipg; if (got_siginfo) { printf("%s: phase 1: cyl group %d of %d (%d%%)\n",