Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 24 Sep 2007 16:30:00 -0700 (PDT)
From:      Don Lewis <truckman@FreeBSD.org>
To:        samflanker@gmail.com
Cc:        freebsd-hackers@FreeBSD.org
Subject:   Re: fsck of large volume with small memory
Message-ID:  <200709242330.l8ONU0IT008004@gw.catspoiler.org>
In-Reply-To: <46F7CCF8.5010402@gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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",




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200709242330.l8ONU0IT008004>