"Cannot find file system superblock" error - how to recover?

Sergey 'DoubleF' Zaharchenko doublef at tele-kom.ru
Thu Dec 4 07:03:14 PST 2003

On Thu, 4 Dec 2003 06:17:40 -0800 (PST)
"Scott I. Remick" <scott at sremick.net> probably wrote:

> --- Sergey 'DoubleF' Zaharchenko <doublef at tele-kom.ru> wrote:
[so you want the list cc'd. good...]
> > Oh yes there are... what's surprising? If you are sure that the problem
> > is with the superblock, pick any you wish.
> > 
> > The actual number of superblock copies depends on the disk size and the
> > parameters you give to newfs.
> [...]
> > It's about THE superblock, not a superblock copy. There can be only one
> > superblock. There may be many copies. But if you dd them to the
> > superblock, that'll be fine.
> Ahh ok, I've learned something new. Guess I misinterpreted the information I
> found online. I'm not complaining: this is GOOD news. :)
> > BTW, what's the output of ``disklabel -r /dev/ad6s1c'' ?
> su-2.05b# disklabel -r /dev/ad6s1c
> # /dev/ad6s1c:
> 8 partitions:
> #        size   offset    fstype   [fsize bsize bps/cpg]
>   c: 156344517       63    unused        0     0         # "raw" part, don't edit
>   e: 156344517       63    4.2BSD     2048 16384    89
> partition c: partition extends past end of unit
> disklabel: partition c doesn't start at 0!
> disklabel: An incorrect partition c may cause problems for standard system
> utilities
> partition e: partition extends past end of unit
> That doesn't look good.


> By the way, the past posts I've read suggest that even if I use fsck_ffs -b
> to run fsck with a diff superblock (say, the one at 160) that it doesn't
> actually fix the master copy, and that I still need to use dd to fix the
> original. The command I've seen used is:
> dd if=/dev/ad6s1c skip=32 of=/dev/ad6s1c seek=16 bs=512 count=16

In fact, when you mess with superblocks, it's messing with filesystems
(thus it's different from messing with disklabels). So I guess you
should use /dev/ad6s1e here. `e' should be the partition, and `c' ---
the whole disk.

> 1) Do I just replace the 32 of "skip=32" with 160 (or whichever superblock
> makes fsck_ffs -b happy)?

Probably yes. The thing is you want to copy some 8192 bytes from one
location to another. But I never had a chance to treat a superblock
that way... Go ask a person who did!
> 2) I've also read that the size and location of the original superblock can
> vary. Do I have to modify the seek/bs/count values to account for this? And

Yes. skip here is the location of the copy, seek is the location of the
superblock (see below for values).

> if so, how do I find the proper values?
> Nothing done yet... don't wanna screw this up. Thanks everyone!

If you want to be more sure, try dd'ing your (suspectedly damaged)
superblock and some of its (suspectedly OK) copies into different files:

# dd if=/dev/ad6s1e skip=... bs=512 count=16 of=somefile

As /usr/src/sys/ufs/ffs/fs.h suggests, for THE superblock skip should be
16 if you have UFS1 or 128 or 512 if you have UFS2 (if my maths is
correct). These commands shouldn't do anything harmful to /dev/ad6s1e.

Of course, after that, you could hack up a program which will read
superblocks and display them according to their structure defined as
`struct fs' in /usr/src/sys/ufs/ffs/fs.h. Let's not do it today, right?

If your superblock copies will appear similar to each other (use cmp(1)
or md5(1)), then you can be sure that you've found the copies (so far
you haven't done any mistakes in your calculations). Then it's up to you
to commit the change.

I've just tried it on a test machine. The copies matched. Hmm:)

> =====
> Scott I. Remick   --==--   ICQ: 450152 
> Save the internet - Use a Mozilla-based browser: http://vtbsd.net/mozilla/
> FreeBSD: Because making unix user-friendly is easier than debugging Windows. http://vtbsd.net/freebsd/
> "Voici mon secret. Il est tres simple: on ne voit bien qu'avec le coeur. L'essentiel est invisible pour les yeux."
> Q: Because it reverses the logical flow of conversation.
> A: Why is putting a reply at the top of the message frowned upon?
> _______________________________________________
> freebsd-questions at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org"

Peter's Law of Substitution:
	Look after the molehills, and the mountains will look after
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20031204/a654d7a7/attachment.bin

More information about the freebsd-questions mailing list