Subject: Re: Accessing ext2fs from NetBSD/alpha?
To: None <email@example.com>
From: None <firstname.lastname@example.org>
Date: 05/23/1999 22:06:28
Quoting der Mouse <mouse@Rodents.Montreal.QC.CA>:
> > I'm a new user of NetBSD, and so far have been quite impressed with
> > it.
>> The only problem I have is getting data from an ext2 partition on my
> > alpha's secondary disk (sd1) after migrating from Debian Linux to
> > NetBSD. [...]
> > Anyway, I'm curious if NetBSD/alpha can read PC-style partitions (the
> > partition in question was made with Debian/alpha, by its fdisk).
> I don't know this. But I maybe can help a little....
> Disclaimer: I've never tried NetBSD ext2fs support at all, much less on
> an alpha. But I have no reason to think it doesn't work.
> It seems to be the biggest problem is finding the filesystem; since
> mounting the whole-disk partition didn't work, it probably (as you
> surmise) isn't starting at offset zero.
> If I were faced with that problem and couldn't somehow get the disk and
> Linux together on the same machine, what I'd probably do is this:
> - Write a small program (based on the NetBSD ext2fs code) to check
> whether a given block could be an ext2fs superblock. (Rudimentary
> checks like magic number and reasonable values for some superblock
> fields (eg, filesystem sizes larger than the disk are out). If the
> ext2fs superblock has redundant fields (I know ffs does), check them
> for consistency.)
> - Use this program to scan the disk and collect a list of blocks that
> might be superblocks.
> - Figure out (again, based on the ext2fs support) what the offset is
> from the beginning of the partition to the superblock (eg, the
> analogous value for ffs would be 8K).
> - Try partitioning the disk in the NetBSD way, placing the partition
> beginnings so as to put the various possibly-superblocks in the
> superblock position in the partition.
> - Run fsck_ext2fs -n on each attempted partitioning to see if it's
There's a program at http://bmrc.berkeley.edu/people/chaffee/fat32.html called
"If you somehow manage to corrupt your PC disk partition table, this Linux
utility will attempt to recover it. It scans the disk looking for filesystems.
It currently tries to recognize partitions of type FAT16, FAT32, NTFS, UFS,
EXT2, or BSD disk labels."
It was written for Linux originally, afaik, but it has some FreeBSD tests in the
./configure script, and #ifdefs in the code for FreeBSD configurations. I
haven't tried it on the NetBSD box yet, as I'm away from it atm, but perhaps
this would be a good place to direct your attention if you'd like a programming
challenge (assuming it doesn't work out of the box) ;) I found it after my
g/f's dual boot win95/linux machine had its partition table corrupted by mcaffee
scan, and I used it to successfully rebuild the table (it ended up offset by a
cylinder, but a bit of fdisk experimentation fixed that).
> I realize this may not be a whole lot of help, since it assumes a
> nontrivial degree of programming knowledge and skill, and a readiness
> to dive in and get your hands dirty with relatively complicated bits of
> the system. Unfortunately, I don't know of any ready-to-roll program
> that does what you're after. Also unfortunately, I don't have any
> ext2fs filesystems around, or I might try it myself. (How big is the
> disk, and is what's on it sufficiently sensitive that you wouldn't want
> to let a copy get out? I'm considering dumping a dd image of the disk
> on a NetBSD/alpha machine I have access to and trying more or less what
> I've outlined above...but of course my doing that would require that
> the disk be small enough for it to fit, and that you be willing to
> trust me with a copy of the data.)
The disk is 4gb, which doesn't really facilitate transferring it around. ;)
Perhaps a dd of the beginning part, enough to get to the start of the ext2
partition would be enough? Also, I'm a bit concerned with damaging the
partition with disklabel. I'm not too familiar w/ the tool, but I have made a
backup of the first part of the disk with dd, as outlined in some mailing list
posts on netbsd-users a while back. It definitely wouldn't be beneficial to
overwrite the beginning of the ext2 partition. As the first rule of medicine
goes: "First, do no harm."
The offset idea sounds good, though. When I do get to the machine's location,
it sounds like a good place to start, along with the fixdisktable proggy.
Thanks for the response!