Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 26 Aug 1998 22:46:15 +0200
From:      Stefan Eggers <seggers@semyam.dinoco.de>
To:        Mikhail Teterin <mi@video-collage.com>
Cc:        seggers@semyam.dinoco.de (Stefan Eggers), current@FreeBSD.ORG
Subject:   Re: recovering disk 
Message-ID:  <199808262046.WAA26730@semyam.dinoco.de>
In-Reply-To: Your message of "Wed, 26 Aug 1998 15:22:37 EDT." <199808261922.PAA16299@xxx.video-collage.com> 

next in thread | previous in thread | raw e-mail | index | archive | help
[Now the questions is how often this happens.  Would it be worth to
make an additional disklabel and - for systems having it - fdisk 
partition table recovery tool?  How's the opinion on this?]

> So, the first backup superblock is right next to the main one?

Right.  That's at least what I saw all the time when I used newfs.
The main one is at sector 16 and the first alternative superblock
ended up beging at sector 32.  With default parameters the next one
was 65536 sectors away but that changed with different parameters.  I
don't know how this gets calculated and would have to look at the
code.

> Ok. The disk was mounted at the time of the crash. Would not the
> super blocks differ?

The magic number is in the right place and the parameters are of
course the same.  What differs is the clean flag and maybe some other
unimportant data.

> So, how did you get it back?

The start was clear from the two superblocks occuring in succession.
The field fs_size in the superblock told me how large it was.  That
was fortunately all I needed.

My alternative plan for recovery (in case the superblocks were not
that clearly marking the filesystem start because the were over-
written) was to take the distance between two cylinder group blocks
(see /usr/include/ufs/ffs/fs.h) and the ordinal number of the blocks
to calculate where cylinder group 0 would start, subtract from that
two times the size of the superblocks and an additional 8 KByte which
are reserved for the disklabel and don't get used by the FFS file-
system code.

Both I did with reading 8 KByte blocks and advancing 8 KByte.  For
other block sizes one will probably have to reduce it.

I checked the magic numbers for the block and if it like either one
extracted the information I needed.  For the superblocks I choose
fs_size and for the cylinder group blocks cg_cgx which is their
ordinal number starting from 0 for the first one as far as I remem-
ber.

> Yes... Still, any chance I can re-create the partition table (with
> fdisk) and disklabel?

Once you found your filesystems you are probably able which ones were
in the same disklabel.  That's the disklabel.

And as there is one disklabel per fdisk partition a little thinking
should get you to the values for fdisk.  I won't write it here as I
most likely will get it wrong (it's nearly 11:00 p.m. here).

The CHS information in the fdisk partition table is hard to get right
by hand but I think fdisk can calculate them once you give it the
correct BIOS geometry.  As far as I know this is only used in the BIOS
to locate the partition's boot block.

Stefan.
-- 
Stefan Eggers                 Lu4 yao2 zhi1 ma3 li4,
Max-Slevogt-Str. 1            ri4 jiu3 jian4 ren2 xin1.
51109 Koeln
Federal Republic of Germany

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message



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