Subject: Boot device confusion
To: None <tech-kern@netbsd.org>
From: Allen Briggs <briggs@netbsd.org>
List: tech-kern
Date: 06/20/2005 12:28:58
It seems that BIOS RAID implementations are getting more popular.  In
these, the BIOS interface on a controller can configure and read some
basic RAID set ups, but the disks are exposed to the OS like regular
disks.

So this new Supermicro motherboard I have here has two disks on two
SATA channels.  The OS sees wd0 and wd1.  During boot, I get a nice
Adaptec HostRAID configuration utility and I can create a RAID0 or
RAID1 from there.  The BIOS will then understand how to boot off
the RAID.  I've adapted FreeBSD code so that after we see wd0 and
wd1, we also configure ld0 to match the BIOS RAID configuration.
The RAID begins at sector 0 on the disks, so the disklabel for the
RAID is also the disklabel for wd0.

The x86 findroot() looks at the disklabel information to determine
if it has the right root device, so it finds both wd0 and ld0 in
my case.  It chooses the first one it finds (in a search of alldevs).
This is wd0, which is not what we want--especially for a RAID0 where
the boot fails soon after because it can't read the ffs.

There are four possible solutions that I see to this:

	* Pick the last device instead of the first
	  However, there is a comment:
		 * Use the first match anyway
		 * because lower devices numbers are more likely to be the
		 * boot device.

	* Compare the disk size with the label size
	  This requires some method of getting the disk size from the
	  disk device.

	* Teach the loader about these BIOS RAID things
	  Then we have two places to add new formats--FreeBSD has
	  a bunch of these.

	* Mark devices that should not be included in the findroot
	  process.  So the ld_ataraid bits would, in my case, mark
	  wd0 and wd1 device structures when it attaches the ld
	  made up of those two disks.  This could presumably be a
	  new dv_flag (DVF_MEMBER ?).  If this could somehow be
	  exposed to sysinst, it could remove the member units
	  from the available installation media list, too (also
	  useful for RAIDframe units).

The last seems the least invasive.  Or have I overlooked another
reasonable approach?

Thoughts?

Thanks,
-allen

-- 
                  Use NetBSD!  http://www.NetBSD.org/