Bootloader on SD Card directing to another HDD?

I've been really pulling my hair out with this one. Got a bit of a tricky hardware setup with SATA1-4 as raidz3, and SATA5 as the encrypted ZFS root os disk: The caveat being that I cannot boot from this drive via the BIOS when SATA1-4 are installed, so I need to boot to an SD card and have that bootloader redirect to the fifth disk somehow.

The trouble is I cannot for the life of me figure this out. The closest I've gotten is putting an mbr and bootcode on the sdcard, and installing (I'm approximating from memory)
Code:
boot0cfg -B -d 0x8* da0
, which I gather is how I reference other drives, but unfortunately I think the disk ordering changes when I plug in the first four drives and go to boot from the SD card, so I cannot seem to get a proper boot. So far I've only managed to get a bootloader such as:

Code:
F1 ?

F5 Disk 1

boot>

and pressing F5 just gives me the error when you try to boot a raidz disk.

I'd really appreciate any help in this!
 
It is easy.
I did that decades ago when there were HDD controllers not supported by some PC BIOS. (they were enabled by an own BIOS but the main BIOS had no provision to boot from other than the standard MFM controller)

I wrote a small assembly file and that got booted by diskette.
It was very simple.
First put into the memory address denoting the drive index to boot the drive you want to boot and then execute INT 19h (or the like).

I am lazy and so I only give you a link where you can find the memory locations I spoke of.
 
It is easy.
I did that decades ago when there were HDD controllers not supported by some PC BIOS. (they were enabled by an own BIOS but the main BIOS had no provision to boot from other than the standard MFM controller)

I wrote a small assembly file and that got booted by diskette.
It was very simple.
First put into the memory address denoting the drive index to boot the drive you want to boot and then execute INT 19h (or the like).

I am lazy and so I only give you a link where you can find the memory locations I spoke of.

I wasn't planning on having to write assembly to achieve this, but I'll give it a shot.
 
I do not know another way to do this, sorry.
And I guess it is more difficult than in the early 1980s.
And back then, I had the BIOS source listing at hand, hard to get nowadays.

It is surprisingly hard nowadays to find information that was back then well known.

Here the description of INT 19h from Brown;s list:
Code:
Values Bootstrap loader is called with (IBM BIOS):
   CS:IP = 0000h:7C00h
   DH = access
       bits 7-6,4-0: don't care
       bit 5: =0 device supported by INT 13
   DL = boot drive
       00h first floppy
       80h first hard disk

What is missing in Ralph Brown's listing, is a crucial detail (see here for more detail):
DL must contain MSB 1 for booting HD
the remaining 7 LSB indicate the index number of the drive to boot. (0 = first drive)
The table is in 40:0 BIOS data area, but probably nowadays the EBIOS data area is being used.

So it's basically a single INT 19h call you need to do, if you know the index number by looking into the tables.
Alternatively you can try 0, 1, 2,... until you found the correct index number.

Then just make a bootable FreeDOS partition and create by hand a .COM file with just setting the registers and the INT19h instruction, which you call in autoexec.bat.
 
Use GPT on the SD card and write gptzfsboot to the freebsd-boot partition. That's all that would be needed, see gptzfsboot(8):
Code:
     gptzfsboot tries to find all ZFS pools that are composed of BIOS-visible
     hard disks or partitions on them.  gptzfsboot looks for ZFS device labels
     on all visible disks and in discovered supported partitions for all
     supported partition scheme types.  The search starts with the disk from
     which gptzfsboot itself was loaded.  Other disks are probed in BIOS
     defined order.  After a disk is probed and gptzfsboot determines that the
     whole disk is not a ZFS pool member, the individual partitions are probed
     in their partition table order.  Currently GPT and MBR partition schemes
     are supported.  With the GPT scheme, only partitions of type freebsd-zfs
     are probed.  The first pool seen during probing is used as a default boot
     pool.

The old bootmanager boot0cfg(8) only supports MBR partitioned disks and UFS. It doesn't support GPT and/or ZFS.
 
SirDice, thanks for the direction. I've been having fun messing around with the assembly bootloader but no luck getting it work. I figured I was using the wrong tools/approach, so thanks for pointing me towards the correct one! Will report back with results.
 
Hm. Not quite there. It seems to first be going to the correct ZFS disk (asks me for my encryption passphrase for that disk) but then tries to boot the wrong ZFS disk (one from the separate raidz2):

Code:
GELI Passphrase for disk5p3: *****************************************

Calculating GLI Decryption Key disk5p3 @ x iterations...
|
Can't find /boot/zfsloader

FreeBSD/x86 boot
Default: raidz2:/boot/kernel/kernel
boot:

here is what I did
Code:
gpart create -s gpt da1

gpart add -t freebsd-boot -l gpboot -b 40 -s 512K da1

gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 da1

I assume the issue is that there are four ZFS disks ahead of the boot disk on the SATA controllers. Unfortunately I cannot change this boot order preference in the system BIOS. Any advice on how to specify a particular disk partition to boot (in this case Disk5p3)?
 
Is it possible to swap some disks around? For ZFS itself the order (or the controller) doesn't matter.
 
The 4 disks in raidz2 are on a SAS, and the root os disk is on a single sata connection on the motherboard directly. The first four disks can be any arrangement but the root disk must be on SATA5.

It's bizarre because it starts to boot from the right disk. Is the original boot partition on the root disk possibly auto searching the drives and finding the raidz2 disks? That would explain the switch from Disk5p3 booting to Disk(1-4) apparently trying to boot, but would be very strange...why would the bootloader on Disk5 go hunting around for another wrong disk to boot? I'm not sure what's going on.

Appreciate the help btw.

Edit: I found this post:

Boot from an approriate distribution CD into "live CD" mode. Log in as root.

Now, let's say your bootable pool is called "tank";

import the pool without mounting it -

zpool import -N -f tank

Then set the bootfs property approriately. A common boot filesystem name is "tank/ROOT/default";

zpool set bootfs=tank/ROOT/default tank

that's it for the bootable pool. Repeat for the non-bootable pool, this time setting the bootfs property to "". There, you're done.

But I'm not sure what I should be setting as bootfs, or whether this is the correct fix. Actually zroot is not listed on the pools from the live boot anyway. I assume because its encrypted?

Edit2:

I'm trying to reinstall with all five drives connected in case the bootloader on Disk 5 was set improperly at the start. Will report back.

Edit3:

Nope same problem. Boots to Disk5 first, then jumps to trying to boot to a disk in raidz2 pool. What the heck?!

Inputting

Code:
boot: zroot:/boot/kernel/kernel

at the failed boot prompt spits out a bunch of memory addresses and hangs. Don't know what else to do here.
 
Back
Top