Using boot0 to redirect booting to another disk?

Bruce Evans brde at optusnet.com.au
Wed Dec 3 12:31:27 UTC 2014


On Wed, 3 Dec 2014, [utf-8] José María Alcaide wrote:

> I have an HP Proliant Microserver Gen8. Nice machine but picky BIOS. When its hard disk controller is configured in SATA AHCI mode, there is no way to choose the boot disk among those connected to the SATA ports. I have four HDD attached to the backplane, and another drive connected to a fifth SATA port originally intended for an optical drive. The four HDD are arranged in a RAIDZ. Currently the machine is booting from an USB flash device, but I would like to boot the FreeBSD installed on fifth drive. The disk controller sees and reports the five disks just fine, but as I said above, there is no way to choose the fifth disk as a boot device.
>
> I wondered whether I could use boot0 to redirect the boot from a USB flash device (pendrive or, still better, a microSD) to the fifth drive. The idea comes from the fact that boot0 shows a "F5 - Drive 2" option when it detects more than one drive. I tried to understand how boot0 works reading its source code, and I experimented with the boot0cfg's "-d disk" and "-o setdrv" options, to no avail. So I decided to ask for help. :) >
> Is that possible? Any help will be greatly appreciated.

boot0 wants to chain to the next drive by loading the boot block (which
contains the new boot program and partition table).  Loading a new boot
program is usually exactly what is not wanted.  It means that to boot
from the fifth drive (Drive 4 (?)) starting from the first drive (Drive 0
(?)), you not only have to hit F5 4 times, but you must put a FreeBSD
boot0 on all disks chained through.  Even when you know this, it is
easy to forget it and chain to nowhere (a data disk with a dummy boot
block on it), or better yet, to a disk with a Windows boot loader on it
that forcinly boots Windows).

The BIOS must support all the disks chained through and the final boot
disk of course.

Your best chance using boot0 is to get the BIOS to boot from the 4th
drive so that the 5th drive is only 1 chaining step away.  Removable
drives probably wouldn't work well for this.  They might be numbered
after the 5 fixed drives so they would be even further away.  Perhaps
the BIOS renumbers all the drives, especially when you don't want it
to.

I don't see how -d drive can work for removable or renumbered drives.
It just allows (when -o setdrv is also configured) overriding the
default drive number.  There is no standard way to determine to current
drive number and it is sometimes misguessed.  -d drive -o setdrv gives
a way to force a fixed number.  But when the drive is removable or
renumbered, no fixed number can work.  -d is also useless for booting
from the 5th drive starting from another drive, except possibly using
hacks like giving the drives the same partition table -- then the
current partition table is correct for the new drive and lieing to the
BIOS about the current drive number makes it load the next boot block
(normally boot2) from the new drive.

This bug is partly due to boot0 being optimized for space.  It uses almost
identical code to chain to the next drive as it does to chain to a boot
block on the current drive.

More practically, don't use boot0 for this.  Boot as far as boot2 from
some drive supported for booting by the BIOS, then go from there to the
final drive.  This requires a tiny FreeBSD file system on the boot
drive to hold /boot.config.

Bruce


More information about the freebsd-fs mailing list