Subject: Re: disklabelling an ide drive
To: schaecsn <schaecsn@gmx.net>
From: Frederick Bruckman <fredb@immanent.net>
List: port-mac68k
Date: 08/26/2002 20:06:56
On Mon, 26 Aug 2002, schaecsn wrote:

> # schaecsn> - Netbsd looks for the root filesystem on wd0a - mine is
> at wd0b. Since it's not found on wd0a I get prompted in the middle
> of the boot process to enter the proper root filesystem. the same is
> true for swap. Is there a way (bootoption ?) to tell netbsd to look
> for root and swap at wd0b/wd0d?

Partition "a" is the partition with the BZB_ROOTFS bit set, *not*
the first partition on the disk (unless the bit isn't set for any
partition). Likewise, partition "b" is the partition with the
BZB_TYPESWAP bit set. All you need to do is set the bits. The
partition editor in "sysinstall" should be able to do that for you.

It's possible to edit your partition table with a binary editor, but
I wouldn't recommended it without another disk to boot from:

	dd if=/dev/rwd0c bs=4k count=1 of=map.bin
	bvi table.bin
	:set cm=16

["bvi" is available in pkgsrc.]

Now the partition entries start with the magic signature "PM" on 512
byte boundaries (0x200,0x400,0x600). The partition type is set by
bytes start+0x90,start+0x91. It'll be 0xC000 for "Root & Usr",
"0x8000" for "Root", and only "0x4000" for "Usr". In other words,
the most significant bit causes disklabel to slot it as "a". Once
"a" is filled, the first partition encountered with the second most
significant bit set becomes "g".

A partition become "b" by virtue of having start+0x8D set to 0x03.
(That byte should be set to 0x01 for the filesystems.)

Only after searching for the special cases does the kernel disklabel
code start filling in the remaining slots with the remaining
partitions. All these numbers, by the way, can be gleaned from
<machine/disklabel.h>.

After editing the map, you can copy it back to disk with

	dd if=map.bin bs=4k count=1 of=/dev/rwd0c conv=notrunc

repeat until the you hear the disk seek, indicating the cache has been
flushed. See if "disklabel" returns different results. If you had
partitions mounted on that disk, watch it panic().	;-)


Frederick