Mounting raw disk backup file.

2012-08-06 Thread Matthew Navarre
HI,
I had a drive fail recently, it was working fine until I rebooted. After
that the partition map was corrupt and I can't mount either partition on
the disk. So I made a copy of the whole disk using dd to an old USB drive.
There were several IO errors while dd was copying the disk, so I think the
disk is starting to go.

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.

So, any suggestions?

Here's what file says about the file:
mnavarre@pcbsd-1810] /# file /mnt/ada1_backup
/mnt/ada1_backup: x86 boot sector; partition 1: ID=0xa5, active, starthead
1, startsector 63, 167766732 sectors; partition 2: ID=0xa5, starthead 254,
startsector 167766795, 144809910 sectors, code offset 0x3c, BSD disklabel

And just for grins, what fdisk says about the actual disk:
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:
UNUSED
The data for partition 4 is:
UNUSED

Thanks,
Matt Navarre
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Mounting raw disk backup file.

2012-08-06 Thread Michael Sierchio
On Sun, Aug 5, 2012 at 11:12 PM, Matthew Navarre
navarre.matt...@gmail.comwrote:


 I had a drive fail recently, it was working fine until I rebooted. After
 that the partition map was corrupt and I can't mount either partition on
 the disk. So I made a copy of the whole disk using dd to an old USB drive.
 There were several IO errors while dd was copying the disk, so I think the
 disk is starting to go.

 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.

 So, any suggestions?

 Here's what file says about the file:
 mnavarre@pcbsd-1810] /# file /mnt/ada1_backup
 /mnt/ada1_backup: x86 boot sector; partition 1: ID=0xa5, active, starthead
 1, startsector 63, 167766732 sectors; partition 2: ID=0xa5, starthead 254,
 startsector 167766795, 144809910 sectors, code offset 0x3c, BSD disklabel


Why did you put it in /mnt?  That's customarily used for mounting
fileystems.  Move it ;-)

mdconfig -a -t vnode -f /new-path/ada1_backup

note the device that's created (probably md0)

you can then operate on /dev/md0 as if it were a disk.  In particular, you
might want to fix the partition map, the label info, etc.  You can then
fsck the filesystem (presumably something like /dev/md0s1a or /dev/md0a
etc).

You'll probably need to tell fsck that it's ufs (i.e. fsck -t ufs /dev/md0a
)

you can then mount the fs (mount -t ufs /dev/md0a /mnt )

- M
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Mounting raw disk backup file.

2012-08-06 Thread Polytropon
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

# fdisk /dev/md0

and it should print the same partition table as for the real
disk.

Now you can access and mount from that disk image, e. g.

# mount -t ufs -o ro /dev/md0s1a /mnt

as this maybe is the root file system of the 1st slice. Note
the use of -o ro in this case. If you have had partitioned
your system, you can add those partitions into a fully
accessible /mnt tree for that system disk, e. g.

# mount -t ufs -o ro /dev/md0s1d /mnt/tmp
# mount -t ufs -o ro /dev/md0s1e /mnt/var
# mount -t ufs -o ro /dev/md0s1f /mnt/usr
# mount -t ufs -o ro /dev/md0s1g /mnt/home

Note that unmounting must happen in the reversed order. If there
was another file system, e. g. for sharing with Windows stuff,
it's also possible to mount it:

# mount -t msdosfs -o ro /dev/md0s2 /mnt/win

Of course you can access all slices and partitions independently.
That should be the best approach for recovering data.




-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Mounting raw disk backup file.

2012-08-06 Thread Matthew Navarre
On Sun, Aug 5, 2012 at 11:28 PM, Michael Sierchio ku...@tenebras.comwrote:



 On Sun, Aug 5, 2012 at 11:12 PM, Matthew Navarre 
 navarre.matt...@gmail.com wrote:




 Here's what file says about the file:
 mnavarre@pcbsd-1810] /# file /mnt/ada1_backup
 /mnt/ada1_backup: x86 boot sector; partition 1: ID=0xa5, active, starthead
 1, startsector 63, 167766732 sectors; partition 2: ID=0xa5, starthead 254,
 startsector 167766795, 144809910 sectors, code offset 0x3c, BSD disklabel


 Why did you put it in /mnt?  That's customarily used for mounting
 fileystems.  Move it ;-)


Heh, the BSD drive with the backup file in on /mnt, the mdconfig node is
md1.


 mdconfig -a -t vnode -f /new-path/ada1_backup

 note the device that's created (probably md0)

 you can then operate on /dev/md0 as if it were a disk.  In particular, you
 might want to fix the partition map, the label info, etc.  You can then
 fsck the filesystem (presumably something like /dev/md0s1a or /dev/md0a
 etc).

 You'll probably need to tell fsck that it's ufs (i.e. fsck -t ufs
 /dev/md0a )

 you can then mount the fs (mount -t ufs /dev/md0a /mnt )


Thanks, didn't realize that I could use that device node to operate on it
like a block device. Of course, the fact that mdconfig makes the system
think a file is a block device should have been a clue ;)

Now I just need to get the partitions and disklabel figured out.


 - M


OK,
MCN
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Mounting raw disk backup file.

2012-08-06 Thread Matthew Navarre
On Mon, Aug 6, 2012 at 12:08 AM, Polytropon free...@edvax.de 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:
UNUSED
The data for partition 4 is:
UNUSED

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.

OK,
MCN
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Mounting raw disk backup file.

2012-08-06 Thread Wojciech Puchar

I had a drive fail recently, it was working fine until I rebooted. After
that the partition map was corrupt and I can't mount either partition on
the disk. So I made a copy of the whole disk using dd to an old USB drive.
There were several IO errors while dd was copying the disk, so I think the
disk is starting to go.


did you use conv=sync,noerror.

if not your backup is quite corrupted if errors were uncorrectable.



So, any suggestions?



repair partition table, use mdconfig and then you will get

/dev/md0
/dev/md0s1...

as with real drive
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Mounting raw disk backup file.

2012-08-06 Thread Matthew Navarre
On Mon, Aug 6, 2012 at 2:55 AM, Wojciech Puchar 
woj...@wojtek.tensor.gdynia.pl wrote:

 I had a drive fail recently, it was working fine until I rebooted. After
 that the partition map was corrupt and I can't mount either partition on
 the disk. So I made a copy of the whole disk using dd to an old USB drive.
 There were several IO errors while dd was copying the disk, so I think the
 disk is starting to go.


 did you use conv=sync,noerror.

 if not your backup is quite corrupted if errors were uncorrectable.


Yep, did that, so I'll lose some data, but that partition is mostly media
and some old MacOS (7/8/9) software, so it'd suck to lose it but wouldn't
be catastrophic. The first partition on the disk is more important.

The ironic thing is that the drives I was going to transfer this data onto
and the external hard drive that was going to be hold the backups are on
their way. Murphy strikes when you least expect it.



 So, any suggestions?


 repair partition table, use mdconfig and then you will get

 /dev/md0
 /dev/md0s1...

 as with real drive


Yep, it's currently the whole repair partition table bit that's giving me
problems. Unfortunately, PC disk geometry is not my forte. I'm hoping I can
find my log book from the system this drive was transfered from, which
should have both the partition map  and the alternate superblocks written
down. My wife probably put it somewhere safe ;)

OK,
MCN
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org