From: alan@nabeth.cxo.dec.com (Alan Rollow - Dr. File System's Home for Wayward Inodes.)
Subject: Re: Wrote over the RZ26L disklabel
Date: 1996/04/12 [thread overview]
Message-ID: <4km2ma$14m@nntpd.lkg.dec.com> (raw)
In-Reply-To: 316D7FCA.41C6@globalcom.net
In article <316D7FCA.41C6@globalcom.net>, John Sanders <jsanders@globalcom.net> writes:
>I distroyed the disklabel on the RZ26L I was using as the system disk on
>my AlphaStation 400. I dodnt remember exactly how the disk was
>configured. I used disklabel to put a new label on the disk and edited
>it to show the BSD file system. The "a" partition works fine - mounts
>just fine - but I need the "g" partition where the /usr stuff is
>located. fsck just complains about the "magic number" of the superblocks
>being fouled up. Probably because the start of the partition or its size
>is wrong. Is there anything I can do to find the start and extent of the
>"g" partition on this disk?
If the file systems on the disk are UFS, then it may be possible to reconstruct
enough of the partition table. It may be possible with AdvFS, but the on-disk
format is too under-documented.
A UNIX File System starts with space for a boot block. 8 KB of space is
set aside for it, even when the partition isn't bootable. The next 8 KB
is the primary superblock. The next 8 KB is the backup superblock. Since
superblocks have magic numbers and other fields that can help uniquely
identify them as superblocks all you need to do is:
1. Open the raw device.
2. Read 8 KB and see if it is a superblock. If so, read the next 8 KB
and see if it is a superblock. Once you have to superblock back to
back, then you probably have the primary and first backup. The start
of the partition is 8 KB back from the start of the first one. The
(used) size of the partition is one of the fields in the superblock.
Note: I said *used* size because the newfs command supports a
-s option to explicitly set the size. Since newfs verifies that
it can write the last sector of a partition, you can't lie and
use a larger size. But you can use a SMALLER size. The actual
partition may be larger.
3. If the first 8 KB from #2 isn't a superblock, advance the offset one
sector and repeat step #2.
4. If you think other filesystem may be on the disk, you can either
continue the search from the last superblock pair found, in case
those weren't a file system or from the end of the file system
you did find.
Hints for writing such a program:
1. You'll need to include <ufs/fs.h> and anything it requires. It
so happens that on Digital UNIX V3.0, <ufs/fs.h> is sufficient.
2. The data structure for the superblock may be larger or smaller
than 8 KB. Use SBSIZE for doing I/O, not the size of (struct fs).
>
>Thanks in advance -
>
>--
>_____________________________________
>john sanders <jsanders@globalcom.net>
>
> >- it can be done -<
>
>-------------------------------------
>
--
Alan Rollow alan@nabeth.cxo.dec.com
next prev parent reply other threads:[~1996-04-12 4:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-04-11 4:00 Wrote over the RZ26L disklabel John Sanders
1996-04-12 4:00 ` Alan Rollow - Dr. File System's Home for Wayward Inodes. [this message]
1996-04-23 4:00 ` "Mark Jeffery"
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox