Subject: More on the esp driver and large hard drives
To: port-mac68k <port-mac68k@NetBSD.ORG>
From: Frederick Bruckman <fredb@fb.sa.enteract.com>
List: port-mac68k
Date: 05/01/1998 21:28:21
I've managed to resolve a long standing problem with my system by fiddling
with the partition table on the drive in question. The key to the solution
is that NetBSD must find no more than 8 partitions, total, including the
partition table itself, the drivers(s), and any Apple_Free partitions.
It's not always clear how many actual partitions your drive has, as it
depends somewhat on what formatting utility you use, and exactly how you
have used it. A simple test for folks who have been having problems with
large HDs is to count the partitions shown by Mkfs1.45.  (Mkfs seems to
scan the disk at launch the same way NetBSD does on booting.) If Mkfs
shows more than _six_ partitions, this applies.

I suspect large drives, and certain makes of drives, have been getting a
bum rap over this. Larger drives, for one, are more likey to have multiple
partitions, or to have had multiple partitions. Deleting the last
partition with a MacOS utility like FWB Tools, or LaCie's Silverlining
just changes the count in the partition map. The is all MacOS needs to
ignore that entry, but NetBSD (and Mkfs) ignores the count and finds what
looks like a (ninth, tenth) valid partition, setting the stage for later
failure.

This may apply to Jazz, Syquest, and other removables, too.  My first try
at setting up NetBSD on a Syquest compatable Noami540MCD, with FWB Tools,
give me a partition map, a SCSI driver, shared driver objects, an IDE
driver (just in case!), an HFS partition, root, swap, user, and a 1/2k
Apple_Free partition, for a grand total of 9 partitions. I had managed to
get that setup to work by zapping the IDE driver _before_ installing the
other partitions. That's been working well for some time. I have only got
that esp timeout once, recently, when playing with a scratch disk that
failed to format under MacOS.

My 3.2G Arriva (QUANTUM) proved to be a little tougher. Even after cutting
down to six visible partitions, and editing out the Apple Free junk by
hand, NetBSD wouldn't access the drive at all without crashing. That still
left nine actual partitions, as FWB formatted disks have that "shared
objects" partition. To sum up my experiments, it's sufficient a) to delete
the signature bytes, 0x504D, from the beginning of block nine, and b) to
reduce the partition count at the beginning of block one, so that it reads
'504D 0008'. "a" is what NetBSD wants, "b" is so "a"  doesn't cause MacOS
to hang. This lets disklabel and dd work, and hopefully newfs and
hfsutils. The data in the last partition is still accessable under MacOS
after changing those three bytes back.

I realize this is a long post, but this HD business has been a hassle
since I started getting involved with NetBSD last year, and its very
exciting to me that it's finally working. I'm also curious if this has any
application to the Jazz drives problem. I don't have one to experiment
with, myself. Incidently, here's a command to view your partition
tables, assuming you can access the drive at all. 

  # dd if=/dev/rsdNc skip=1 count=15 | hexdump -vC | less

With this, address 00001000 is the start of naughty partition number nine.