Subject: Re: disklabel vs. mbr partitions
To: Anders Eriksson <aer@cdt.luth.se>
From: Greg Hudson <ghudson@MIT.EDU>
List: netbsd-help
Date: 03/06/1998 13:25:01
Some things to know about the NetBSD disklabel:

	* You cannot label a disk if it doesn't have a NetBSD MBR
	  partition, unless you're using the entire disk for NetBSD
	  and thus don't care about the MBR at all. If you do try to
	  label a disk without a type 169 (or 165) partition, it will
	  write the label on an early sector of the disk, overwriting
	  your MBR partition table.

	* If a disk has no label, the kernel will fake up a label
	  containing (among other things) your MBR partitions.  It
	  will specially recognize MS-DOS partitions and put down the
	  right filesystem type for them (this is a hack).  The kernel
	  will also spew a lot of annoying "no disklabel" messages to
	  let you know that it had to fake up the disklabel.  If you
	  can ignore those, you're set.

Now I'll go through your experiences and explain them:

> The original setup is w95 on wd0 with grub as bootlaoder, netbsd on
> wd1. If i run disklabel on wd0 it finds a msdos partition on
> 'e'. Mounting it gives a line 'No disklabel' and all sorts of
> read/write errors (thrashed files). ls et c works though.

The "No disklabel" error makes perfect sense and you can ignore it.
The "all sorts of read/write errors" suggests that your disk is
failing, or that the driver is messed up, or that something else is
seriously wrong.

> running 
> disklabel -r wd0 > /tmp/label
> disklabel -R -r wd0 /tmp/label

> to write the label on the disk trashes the mbr partition information
> and makes me loose the w95 partition.

Right, disklabel doesn't find a NetBSD partition to write the label
to, so it writes it out to sector (I think) 1, nuking your MBR
partition table.

> Restiring the partition information by hand in fdisk makes it come
> back, but then I get the 'no disklabel' warning. What's up?

Restoring the partition information overwrote the NetBSD disklabel, so
the kernel had to go back to faking up a label.

So, the solution to most of your problem is to ignore the "no
disklabel" warnings and mount your W95 partition using the faked-up
disklabel.  However, the read/write errors indicate a serious problem.