Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 6 Aug 2012 01:55:16 -0700
From:      Matthew Navarre <>
Subject:   Re: Mounting raw disk backup file.
Message-ID:  <>
In-Reply-To: <>
References:  <> <>

Next in thread | Previous in thread | Raw E-Mail | Index | Archive | Help
On Mon, Aug 6, 2012 at 12:08 AM, Polytropon <> wrote:

> On Sun, 5 Aug 2012 23:12:48 -0700, Matthew Navarre wrote:
> > I can probably fix the partition table using testdisk, but now that I've
> > got this image file I'd rather work with that instead of the physical
> disk.
> > I've read the Handbook section on using mdconfig, but that assumes the
> > image file is of a filesystem, not a whole disk. I think I've
> > found instructions for how to do it on linux, but if there's a way to
> mount
> > it on FreeBSD I'd rather do that.
> It depends on _what_ your disk image (typically created by a
> dd-like utility to make a 1:1 copy of a whole disk) contains.
> If there are several slices and partitions, each of them can
> be accessed like it was a physical disk.
> Let's assume you have /home/you/ada1.dd which is the copy of
> your former /dev/ada1 disk. You do:
>         # mdconfig -a -t vnode -u 0 -f /home/you/ada1.dd
> This results in a file /dev/md0 as well as any "partitional
> qualifier specials" that might correspond to the disk the copy
> has been taken from. You can check that with

Yep. Unfortunately the partition table and disklable are screwed, so
md1s(1,2) don't appear in dev. Same with ada1, which is the physical disk.

The drive has two primary partitions, both of which had a single UFS file
system on them. So now I just need to figure out how to fix the partition
table and the disklabel and I should be golden getting the data out. That
drive is getting replaced, though.

>         # fdisk /dev/md0
> and it should print the same partition table as for the real
> disk.
here's the fdisk output for /dev/ada1, which is the real drive:
mnavarre@pcbsd-1810] /# fdisk ada1
******* Working on device /dev/ada1 *******
parameters extracted from in-core disklabel are:
cylinders=310098 heads=16 sectors/track=63 (1008 blks/cyl)

Figures below won't work with BIOS for partitions not in cyl 1
parameters to be used for BIOS calculations are:
cylinders=310098 heads=16 sectors/track=63 (1008 blks/cyl)

Media sector size is 512
Warning: BIOS sector numbering starts with sector 1
Information from DOS bootblock is:
The data for partition 1 is:
sysid 165 (0xa5),(FreeBSD/NetBSD/386BSD)
    start 63, size 167766732 (81917 Meg), flag 80 (active)
        beg: cyl 0/ head 1/ sector 1;
        end: cyl 1023/ head 254/ sector 63
The data for partition 2 is:
sysid 165 (0xa5),(FreeBSD/NetBSD/386BSD)
    start 167766795, size 144809910 (70707 Meg), flag 80 (active)
        beg: cyl 1023/ head 255/ sector 63;
        end: cyl 1023/ head 254/ sector 63
The data for partition 3 is:
The data for partition 4 is:

Now, the first partition looks sane (size is right, geometry looks right).
The second partition, however, looks a bit wrong, since it ends before it
starts, but the size is right.

And now I've gone and screwed up the disk image file. So, it's math and
manpages from here.


Want to link to this message? Use this URL: <>