Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 11 Sep 2005 17:02:05 -0700
From:      John-Mark Gurney <gurney_j@resnet.uoregon.edu>
To:        Andreas Klemm <andreas@klemm.apsfilter.org>
Cc:        hackers@FreeBSD.org
Subject:   Re: need hints to recover lost FreeBSD partition entries in MBR ...
Message-ID:  <20050912000205.GH793@funkthat.com>
In-Reply-To: <20050911093933.GA7277@titan.klemm.apsfilter.org>
References:  <20050911093933.GA7277@titan.klemm.apsfilter.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Andreas Klemm wrote this message on Sun, Sep 11, 2005 at 11:39 +0200:
> I unluckily lost the partition table of my 1st disc in a 2 disc system.
> Tip: avoid gag boot manager and don't do my mistakes ...
> 
> Having a printout of the df command I was able to re-create all of
> my fat32 partitions on disc XP boot and 4x FAT32 in an extended part.
> 
> Now I'm looking for suggestions how to be able to compute the
> correct values for Slice 3 and 4 which I could not recover so far.
> 
> It irritates me a bit, that the slices 1+2 already work so well,
> so theoretically mounting of at least slice 3 should be possible now.
> 
> Or are there some sanity checks in the kernel that only allows
> creating the devices in devfs if the size entries in the disklabel
> and the entry in the partition table of the MBR fit both ??
> 
> Maybe I'm only off-by 1 or 2 cylinders in the partition table.
> 
> Do you know a tool or a method how I can compute/find the start cylinder
> of FreeBSD partitions ?

I've just been working on rewriting ffsrecov in python so that it
supports both UFS1 and UFS2 filesystems...

I've put up a preliminary copy at http://people.FreeBSD.org/~jmg/ffsrecov/
You'll need all three files in the directory.  It uses a modified version
of Dug Song's dpkt for reading data from disk.

It doesn't search out disklabel magic's, but can help you locate your
UFS partitions...  In the old days, the disklabel started as the same
address as the first partion, but newer installs start the first
partition 16 blocks into the disk, so this should give you options
for adjusting where the disklabel might be...

ffsrecov.py -f will return all the block offsets that contain a valid
superblock magic... you can then use -s to print out where the file
system starts... so:

disk=/dev/ad0
size=`diskinfo $disk | awk '{ print $3 }'
for i in `./ffsrecov.py -z $size -f $disk`; do ./ffsrecov.py -z $size -s -o $i $disk; done | sort -u

will print out a list of block offsets where all the file systems start...
(the reason you have to provide size is that I don't have code to detect
the size of disk devices yet)...  becareful, it can take a while as it
scans the disk, or you can scan a smaller part of the disk by replacing
disk and size with the proper settings...

Then you can adjust your partition table to be either at the start of
the x'th filesystem, or 16 sectors before that...

Hope this helps..

Though it might be easier to search for the disklabel magic block
directly...  It wouldn't be too hard to modify the -f to search for a
disklabel magic instead of superblock magic...

Good luck!

-- 
  John-Mark Gurney				Voice: +1 415 225 5579

     "All that I will do, has been done, All that I have, has not."



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