Topic: Booting with USB Drive

Hello.  I posted this at daemonforums.org, I'm posting here as well to get some more opinions if possible:

I've got an external USB drive plugged into my FreeBSD box. Once a week a script runs that backs up to it with rsync.

This is all well and good, but on very rare occasion I might need to reboot that box remotely (I ssh into it from work, for example). And when you reboot it with the usb drive plugged in, it boots to a mountroot prompt and wants me to specify, well, where to mount root!

What I believe we've determined is that when I boot with the USB drive plugged in it's mounting the USB drive first as /dev/da0.  The drive that needs to be /dev/da0 is a logical RAID 5 drive on a HighPoint controller.  We think that's being mounted as /dev/da1, and so FreeBSD can't find where to mount root from.  (If the USB drive is NOT plugged in during boot the RAID 5 drive is mounted as /dev/da0.)

So, the question is, is there a way to mount that RAID 5 drive BEFORE FreeBSD probes USB devices?  Alternately, can I force that USB drive to always mount as /dev/da1 or 2, or anything other than 0?

Thanks.

Re: Booting with USB Drive

On NetBSD you can recompile a kernel that hardcodes the location of the root system - but this could prove messy as if you hardcode it as /dev/da1 and unplug the USB stick when you reboot the root drive wont be found as it'll have been switched to /dev/da0

sad

upon reflection, I'm being a complete waste of time to you - sorry

"UBER" means I don't drink the coffee... I chew the beans instead
             -- Copyright BSDnexus

Re: Booting with USB Drive

Bruco wrote:

is there a way to mount that RAID 5 drive BEFORE FreeBSD probes USB devices?

No, except if RAID 5 is your root partition (well it still is not mounted in usual sense).

Bruco wrote:

Alternately, can I force that USB drive to always mount as /dev/da1 or 2, or anything other than 0?

No, and there is no point in doing such thing, numbers represents order of appearance in system. You should instead label device and its partitions using glabel(8).

Re: Booting with USB Drive

WIntellect: It's not a waste of time!  Anything that's brought up will only serve to teach me more, which is good as I'm only a few months into learning BSD.

Here's what I'm going to try tonight, based on suggestions from ephemera at daemonforums.  I'm posting them here in case they can help someone else out some time:

First I'll boot into single-user mode.

Then I'll label each of my mountpoints with tunefs as such:
tunefs -L root /
tunefs -L tmp /tmp
tunefs -L usr /usr
tunefs -L var /var

Then I'll change my /etc/fstab file to reflect these new labels.  For instance:
/dev/da0s1a (which is mounted to /) will become /dev/ufs/root
/dev/da0s1e (mounted to /tmp) will become /dev/ufs/tmp

Then I'll add the following line to my loader.conf:
geom_label_load="YES"

This still leaves the swap partition (/dev/da0s1b).  I can't label it because there's no mountpoint.  What ephemera suggested is that I add an additional swap line to my /etc/fstab for device /dev/da1s1b.  The logic behind this is that if the USB drive is plugged in, it is assigned da0, and my RAID 5 drive gets da1, so the swap will be /dev/da1s1b.  If the USB drive is NOT plugged in at boot, my RAID 5 drive will be da0 and the swap wil be /dev/da0s1b.  Either way swap should be one of those two devices, so while I will probably get an error during boot, (since one or the other will always be invalid) it should still work.

I'm gonna try it tonight and see how it goes!

Last edited by Bruco (2008-05-15 15:41:14)

Re: Booting with USB Drive

richardpl: I was typing and posted my message before yours had been posted.  I'm not ignoring your suggestion!  I'll look at the glabel command too, thank you.

Re: Booting with USB Drive

Update:

The plan worked!  I tried booting with and without the USB drive and FreeBSD loads fully.

Thanks for the suggestions!