Subject: Re: Mounting partition from Mac disk on NetBSD/i386
To: None <netbsd-help@netbsd.org>
From: Christoph Leuzinger <chris+ml@westworks.ch>
List: netbsd-help
Date: 11/01/2007 18:59:31
Hi Patrick!

Patrick Welche <prlw1@newn.cam.ac.uk> wrote:

> On Sun, Oct 28, 2007 at 10:38:41PM +0100, Christoph Leuzinger wrote:
> > I'm attempting some data recovery after my iBook died (again). I took
> > the iBook's hard drive and put it in my NetBSD/i386 box. Now I'd like
> > to mount an ext3 partition that is located on that disk.
> 
> I was about to write "given the information from pdisk, you can write
> a disklabel", which is true, but once you have done that, can NetBSD
> mount ext3 disks, or just ext2 disks? (I haven't needed to try...)

Great, that's the (kinda obvious) piece I was missing! Thank you, Patrick.

NetBSD indeed is able to mount ext3 filesystems, because one of the ext3
design goals is full ext2 compatibility, see [0].

I will now document the steps for recovering the data on that Mac disk, so
that future generations may share this secret. :-)

1) I created a complete backup of the disk using dd(1). The "count"
   parameter is taken from the pdisk output (see my previous posting).

   # dd if=/dev/wd0d of=ibook.img bs=512 count=58605120

2) I then created a vnode disk of the copy using vnconfig(8):

   # vnconfig vnd0 ibook.img

   (I guess it's safer to experiment on a copy of the data I
   was trying to recover than to work on the disk itself.)

3) I wrote a disklabel for vnd0 corresponding to the pdisk output:

   # disklabel -e vnd0

   I changed the slices section to the following:

8 partitions:
#        size    offset     fstype [fsize bsize cpg/sgs]
 a:        63         1     unknown     0     0     0  #
 b:      4096        64     unknown     0     0     0  #
 d:  58605120         0     unused      0     0        # 
 e:    258048      4160     swap        0     0     0  #
 f:  20709376    262208     unknown     0     0     0  #
 g:   1572865  20971584     swap        0     0     0  #
 h:  36060671  22544449     Linux Ext2  0     0     0  #

4) Tried to mount /dev/vnd0h, but got an "incorrect superblock" error.
   Installed sysutils/e2fsprogs and ran

   # e2fsck /dev/vnd0h

   which recovered the journal.

5) Mounted /dev/vnd0h. Hooray!

Cheers,
  Chritoph

[0] <http://www.redhat.com/support/wpapers/redhat/ext3/why.html>