Subject: Re: Multiboot support for review
To: None <tech-kern@netbsd.org>
From: George Georgalis <george@galis.org>
List: tech-kern
Date: 02/01/2006 00:00:38
On Tue, Jan 31, 2006 at 09:19:21PM +0100, Julio M. Merino Vidal wrote:
>
>after some hacking days, I've finally got some code to make NetBSD
>Multiboot-compliant.  We already discussed this here and all I got
>was positive feedback:
>
>	http://mail-index.netbsd.org/tech-kern/2005/12/28/0008.html

>Here come some things I'd like to discuss:
>
>- In the past days, someone suggested the idea of adding a textual
>  data representation to pass variable/value pairs between the kernel
>  and userspace.  I've had to do something similar to pass some boot
>  information between GRUB and the kernel, and hence implemented such
>  an interface.
>
>  It is currently very, very simple, but it may do the job in the
>  cases where it's needed (e.g., mount(2) arguments).
>
>  It is named 'optstr' and is implemented in sys/optstr.h and
>  kern/subr_optstr.c.  See the manual page in the patch file.


I have a frustrating problem that I'd like to point out; maybe you
have some ideas but I'm not sure if it has or could have anything
to do with the stage you are working on...

Hardware:
x86 mobo
two pci based SATA channels
two onboard SATA channels
two onboard PATA channels (=4 devices)
small disk on primary PATA controller
cdrom drive on secondary PATA controller
large disk on each SATA channel
drive trays allowing rotation of SATA drives

Plan:
install OS on PATA disk
use SATA drives for NAS and removable storage

Problem:
init numbers drives in this order: pci SATA, onboard SATA, onboard PATA
(I'm not blaming init, it may be a wacko bios providing the devices
in the wrong order, but I've not been able to try in other hardware)

The net result is, there must be exactly the same number of SATA
drives in place at boot, as during the install; otherwise BIOS
hands over a ro root mount, on the PATA drive, to init, which
proceeds to read the fstab on it and attempt to mount / /var /usr
et al from the wrong device. eg with 4 SATA disks the root fs is on
wd4, with 2 SATA disks the root is on wd2.

BIOS       after init   alt config
PATA        SATA wd0     SATA wd0
            SATA wd1     SATA wd1
            SATA wd2     PATA wd2
            SATA wd3
            PATA wd4

The best solution I have is from an openbsd tech post below.
But, it requires reconfiguring the kernel at boot, each time
the number of disks change -- which is not really an option.

Here is some (openbsd) dmesg,

pciide0 at pci0 dev 15 function 0 "VIA VT8237 SATA" rev 0x80: DMA
pciide0: using irq 11 for native-PCI interrupt
wd0 at pciide0 channel 0 drive 0:
wd0: 16-sector PIO, LBA48, 381554MB, 781422768 sectors
wd0(pciide0:0:0): using PIO mode 4, Ultra-DMA mode 5
pciide1 at pci0 dev 15 function 1 "VIA VT82C571 IDE" rev 0x06: ATA133, channel 0 configured to compatibility, channel 1 configured to compatibility
wd1 at pciide1 channel 0 drive 0:
wd1: 16-sector PIO, LBA, 58644MB, 120103200 sectors
wd1(pciide1:0:0): using PIO mode 4, Ultra-DMA mode 6

"pciide0 at pci0 dev 15 function 0" may well refer to the PATA
drive if no SATA drives are attached, so I'm not sure how to
hardwire a config to always mount the root from the PATA drive.
One could look at the dmesg and see "SATA" or "IDE" pretty quick,
but...

the box has netbsd 3.0 on the "first SATA" and "first PATA"
drives at the moment. So Now I'm wondering.

1) is there a way for the bootloader to educate init
on how to number the drives?

2) if no easy solution exists, what is the most direct way to
install and run?

optstr got my attention for the former, but not sure if it would
help here -- well being able to rewrite fstab from grub would be
really helpful.

The latter may not be as direct as it seams. If I choose to
"always" keep 4 sata drives installed and run the OS from the
pata, I cannot use the installer because it won't see wd4, only
0,1,2 and 3 -- so I still have to boot a netbsd cdrom to mount the
pata partition and change the fstab entries to wd4.

*sigh* -- well I was just wondering if a new bootloader would help...

// George



Date: Thu, 15 Sep 2005 16:33:16 -0700
Message-ID: <15237.1126827196@dumbcat.snafu.org>
From: Marco S Hyman <marc@snafu.org>
To: tech@openbsd.org
Subject: Re: problems with disk numbering

Overkill.   config -e is your friend.   It's easy enough to change the
kernel config.   Take a look at the /usr/src/etc/etc.sparc/Makefile.inc
to see how it uses config -e to create bsd.scsi3 from bsd.   The same
type of thing can be done with wd devices.  I have to do something similar
to run GENERIC on my amd64 as root is on PATA for historical reasons, but
the SATA drive is found first.

neko[etc]$ config -e /bsd.generic
OpenBSD 3.8 (GENERIC) #46: Mon Sep  5 10:13:03 PDT 2005
    root@neko.snafu.org:/usr/src/sys/arch/amd64/compile/GENERIC
warning: no output file specified
Enter 'help' for information
ukc> find wd
 37 wd* at pciide* channel -1 flags 0x0
ukc> add wd0
Clone Device (DevNo, 'q' or '?') ? 37
Insert before Device (DevNo, 'q' or '?') ? 37
 37 wd0 at pciide* channel -1 flags 0x0
ukc> add wd1
Clone Device (DevNo, 'q' or '?') ? 37
Insert before Device (DevNo, 'q' or '?') ? 37
 37 wd1 at pciide* channel -1 flags 0x0
ukc> find wd
 37 wd1 at pciide* channel -1 flags 0x0
 38 wd0 at pciide* channel -1 flags 0x0
 39 wd* at pciide* channel -1 flags 0x0

This makes the SATA drive match as wd1 and the PATA drive match as wd0.





--
George Georgalis, systems architect, administrator <IXOYE><
http://galis.org/ cell:646-331-2027 mailto:george@galis.org