🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Alan Rollow - Dr. File System's ... Tue, 22 Nov 1994 19:46
Re: how to recover filsystems when partition-table is unknown?
#1
Author: Alan Rollow - Dr. File System's ...
Date: Tue, 22 Nov 1994 19:46
73 lines
4166 bytes
In article <3at2cm$j45@sungy.Germany.Sun.COM>, rg@Germany.Sun.COM (Ralph Gerstmann - Sun Germany Product Support - Munich) writes:

> [ Two partitions on a disk, the end of one overlapping the
>   beginning of the other. ]

>the question is: how can i recover the second partition?

First realize that if the first overlaps the beginning of
the 2nd, the 2nd overlaps the end of the first.  The
interestion of the two is corrupt.  So you probably want
to fix the first and get a good backup of it.  Then you 
can worry about the 2nd.

Assuming you're using a file system based on the Berkeley
Fast File System...

Each superblock has a magic number in it that identifies it
as a superblock.  And each superblock is 8 KB long.  But
since you probably don't know there the file system started
you need to read every 8 KB that starts on each sector
boundary from a suitable point after the suspected end of
the first partition:

	/* open a partition of the raw device that overlaps 
	   both the 1st and 2nd file system */

	/* Use lseek to go to a point (sector aligned) that
	   is probably after the end of the 1st file system. */

	/* Read 8 KB and see if this has the magic number of a
	   superblock.  If not, lseek back to a point one sector
	   beyond the previous starting point.  Repeat. */

	/* If the magic number of the block is that of a super-
	   block you have something to work with. */

See if the vendor puts a copy of the partition table in the
superblock (ULTRIX for example, did).  This makes it trivial
to restore the old partition table.  If not, you have to work
a little harder.  You've probably found a backup superblock,
but that's probably not enough to hand to fsck, because you
only know its LBN with respect to the beginning of the disk.
And the superblock probably doesn't identify where it was.

But, the next 8 KB block after the backup superblock is the
cylinder group block.  And that does identify which cylinder
group it belongs to.  Once you know that can work backwards
through the backup superblock rotation algorithm until you
get the LBN of the first backup superblock, which is probably
32 sector from the beginning of the partition.

The file system macro cgsblock(struct fs *, int cgn) is
used to calculate the starting point of a backup superblock
given the cylinder group number.  The value it "returns"
is a file system fragment number.  The macro fsbtodb will
convert that to a disk block number.� The cgsblock macro
in turn uses cgstart, which uses cgbase.

It will probably be a bit of work, but once you know the
cylinder group number associated with a particular backup
superblock and have the other fields of the superblock
intact, you can work out the original partition offset
of the superblock and knowing its position relative to
the beginning of the disk, figure where the partition
started.

>rgds, ralph
>
--
Alan Rollow				alan@nabeth.cxo.dec.com

Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads