On Thu, 8 Oct 2020 at 20:13, Greg Troxel <g...@lexort.com> wrote: > > David Brownlee <a...@netbsd.org> writes: > > > I have a filesystem failing fsck with "bad inode number 34610688 to > > nextinode" and its not in a convenient place to copy all data off to > > rebuild, so I'd like to investigate options to clear the affected > > inode. > > > > The message is triggered from pass1.c > > > > for (ii = 0; ii < inosused; ii++, inumber++) { > > if (inumber < UFS_ROOTINO) { > > (void)getnextinode(inumber); /* <------ > > here */ > > continue; > > } > > > > Adding a quick printf before that loop of > > printf("inumber %llu, inosused %lld\n", (unsigned long long)inumber, > > (unsigned long long)inosused); > > and tweaking the bad inode number message to include lastvalidnum > > > > gives a fair amount of output, ending with: > > > > inumber 34091008, inosused 11264 > > inumber 34194944, inosused 11264 > > inumber 34298880, inosused 11264 > > inumber 34402816, inosused 11264 > > inumber 34506752, inosused 839647232 > > bad inode number 34610688 (max 34610687) to nextinode > > > > "one of those things is not like the others". > > It looks like we have a bad inosused, which runs off the end of the > > available space (>.lastvalidinum) This feels like something from which > > fsck could recover? > > Yes, I suppose it could write something, but it's hard to know how. > > I am guessing that in this case you have a sector with junk in it, when > it should be inodes. I wonder about using fsdb to look at it, or > writing something to get a sector and just print the inodes by field > value. > > This may be as simple as zeroing the bad sector.
So far in this case I think fsck has "fixed" the inodes up to lastvalidnum, I wonder if a relatively conservative approach could be to truncate inosused to lastvalidnum? David