forcing system disk to wd0

Previous thread: Separated at birth? by James on Thursday, September 11, 2008 - 5:21 am. (1 message)

Next thread: Little update to authpf by Rafal Bisingier on Thursday, September 11, 2008 - 8:09 am. (11 messages)
To: <misc@...>
Date: Thursday, September 11, 2008 - 3:40 am

I just added a 4 port promise sata card and cannot figure a way of
forcing the sata ports on the motherboard to take precedence over the
sata pci card.

Any pointers to useful info would be greatly appreciated. I guess i'll
have to mess with the BIOS and IRQs but these are, till now out of my
radar.

regards

To: Joseph A Borg <jacborg@...>
Cc: Misc OpenBSD <misc@...>
Date: Thursday, September 11, 2008 - 1:29 pm

I'm mildly interested in this issue. I had a system a while back where
my root fs drive was plugged into the mobo's sata port, but I had a PCI
sata card with a bunch of other drives on it. I only ran Linux on it
(hate to muddy the waters by bring up Linux). Sometimes the root drive
would be "sda1" and sometimes the first drive on the PCI sata card would
be sda1, causing the root drive to get pushed to sde1. However, on
Linux, when you create a file system, it assigns that file system a UUID
which never changes, and which can be referenced in fstab, essentially
eliminating the problem of which drive gets initialized first.

I've never had this issue with OpenBSD because I haven't used it as a
file server (yet). I know this initialization order issue comes up
somewhat frequently on the misc mailing list, but usually the issue is
merely "I added a drive and am too lazy to edit fstab." Not being a
developer, I'm wondering if anybody has considered creating a feature
similar to the one that exists in Linux, or if there's a reason why that
feature shouldn't be added, or if it is merely not enough of a problem
for anybody to get to it yet.

Tom

To: Joseph A Borg <jacborg@...>
Cc: <misc@...>
Date: Thursday, September 11, 2008 - 7:04 am

Better not mess at all. Fix your fstab and all's well.

-Otto

To: Otto Moerbeek <otto@...>
Cc: Joseph A Borg <jacborg@...>, <misc@...>
Date: Thursday, September 11, 2008 - 7:53 am

Right, assuming you don't have to change your boot device in BIOS all
you have to do is do it in fstab.

To: Marco Peereboom <slash@...>
Cc: Otto Moerbeek <otto@...>, <misc@...>
Date: Thursday, September 11, 2008 - 8:52 am

but i'll have to change it every time i add or remove a hard disk
which can be pretty frequent.

if the total number of drives in the system is not the same from boot
to boot, i have to tweak fstab.
is it possible for a future update of OpenBSD to tweak fstab to take
references to the boot drive? that should help a lot in such cases. I
could spout a lot of ideas, like having a unique identifier
(combination of timestamp and netcard/cpu id?) in the boot block for
reference in fstab, but i'm no expert.

Oh well i'll resign to your suggestions and follow a strict workflow:
no superfluous drives at boot and add them just before backup should
do fine, unless anybody has a better idea. I'd hate keeping back-up
drives in the machine for no apparent reason.

At least i don't have to spend more time searching for info as this
seems to be a dead end.

thanks for the feedback all round

regards

To: Joseph A Borg <jacborg@...>
Cc: Otto Moerbeek <otto@...>, <misc@...>, Marco Peereboom <slash@...>
Date: Friday, September 12, 2008 - 1:37 pm

The superblock for each filesystem does contain space for labels, it's
just that mount doesn't look at them. If somebody added some "put my
drives back where they were last time" code, it wouldn't be too hard.

To: Joseph A Borg <jacborg@...>
Cc: <misc@...>
Date: Friday, September 12, 2008 - 1:13 pm

Maybe a stupid idea: Could you hack /etc/rc to add a tiny script that
reads the last line of dmesg to find where the root disk is and then
rewrites fstab dynamically before `mount -a` gets run? I have OpenBSD
on a thumbdrive that will be sd0 typically unless there are other
thumbdrives/SATA drives plugged into the system I happen to be booting
on and so I considered this but wasn't bold enough to edit rc

-Nick

To: Nick Guenther <kousue@...>
Cc: Joseph A Borg <jacborg@...>, <misc@...>
Date: Friday, September 12, 2008 - 6:16 pm

I thought of adding new sysctl(s) like "hw.rooton", even started to hack
but had to stop due to lack of time. :( It should be simple enough IMHO,
though.

--
Best wishes,
Vadim Zhukov

To: <misc@...>
Date: Friday, September 12, 2008 - 8:23 pm

My two cents (your mileage etc.) Having the system disk "just work (tm)" is
a good thing. Having it work in a secure and correct way seems like
something not so trivial. Perhaps linking at least root to the system disk
could be set as a boot option.

A combination of a uuid, boot options, and mount using these two perhaps?

To: Joseph A Borg <jacborg@...>
Cc: <misc@...>
Date: Thursday, September 11, 2008 - 1:01 pm

Ah, so there's the rest of the problem description. (You didn't
initially why the assignments were an issue, so the assumption was
that it was an aesthetic matter. That may sound silly, but people
worry about the silliest things.)

It's possible to hardcode the assignment of drives in the kernel
config. I _think_ this can only be done by compiling a new kernel
completely (i.e., I don't think "config -e" can do it).

(I used to do this for my laptop, so that the main harddrive would
always be wd0, whether or not I had a second drive in the removable
bay. I stopped when ahci support was added, as then the main drive
became sd0 always.)

Basically, you look at the dmesg to see what the chain of devices to
the one you want to hardcode is and then you add explicit lines for
those to your kernel config as special cases. In my case, IIRC, I
added lines that ran something like:
pciide1 at pci0 dev 31 something something something
wd0 at pciide1 flags 0x0000

(My memory says that specifying the involve pciide channel as pciide0
didn't work right; the assignments didn't always occur the way I
expected or something. Forcing it to be pciide1 worked, and then I
could always set wd0 to be the drive on that channel.)

Note: don't alter the GENERIC config. Create a new file that uses
'include' to pull in GENERIC and then follows it with your required
lines.

Of course, compiling your own kernel is taking you out of normal,
supported territory. You'll need to decide whether that's worth the
trade-off. If you aren't comfortable supporting your custom kernel
config, then don't, and use your existing best practices to avoid the
problem. Don't forget to keep an original GENERIC kernel on hand for
confirming and reporting problems.

Philip Guenther

To: Philip Guenther <guenther@...>
Cc: <misc@...>
Date: Thursday, September 11, 2008 - 4:26 pm

the kernel is absolutely something i wouldn't touch, unless it's a
well documented and easy to follow tweak
but thanks for all the detailed info.

Previous thread: Separated at birth? by James on Thursday, September 11, 2008 - 5:21 am. (1 message)

Next thread: Little update to authpf by Rafal Bisingier on Thursday, September 11, 2008 - 8:09 am. (11 messages)