Freebsd – Booting FreeBSD from whole-disk ZFS pool

boot-loaderfreebsdgptpartitionzfs

I have a FreeBSD fileserver configured with one ZFS pool created from whole disk devices. That is, the pool was created like this:

zpool create pool0 raidz ada0 ada1 ada2

This means the disks have ZFS disklabels, rather than FreeBSD disk labels. This is the recommended way of using disks with ZFS:

ZFS can use individual slices or partitions, though the recommended
mode of operation is to use whole disks. [ from zpool(1M)]

Formatting the disks like this maximizes the portability of the filesystem between various ZFS implementations. Unfortunately, it means there's nowhere to put a freebsd-boot partition containing the FreeBSD loader…or at least, I think that's what it means, but I'm looking for confirmation.

The system currently boots from a CF card containing the embedded loader (as well as the /boot directory, although this could live in ZFS just fine). This works just fine, but Im curious — is there any way to install the embedded loader onto the ZFS-labelled disks?

EDIT: I've been trying to answer this myself. I thought maybe I could apply a GPT label non-destructively to the ZFS disks, and then try embedding the boot code — but while the GPT label didn't cause a problem with ZFS, ZFS seems to tromp on the label somehow. So here's a different question: does OpenSolaris support GPT disk labels? The ultimate goal here is to have a disk pool that will work under both FreeBSD and OpenSolaris while being able to boot from it into FreeBSD.

Best Answer

Well, it's looking like the answer is, "you can't do that".

The rest of this answer is for anybody who happens to come across this entry and is curious about how this is set up:

I have my boot code on a CF card, and everything else (aka, the /boot directory) on ZFS. The CF card is partitioned like this:

# gpart show ad0
=>     34  7847213  ad0  GPT  (3.7G)
       34      128    1  freebsd-boot  (64K)
      162  7847085       - free -  (3.7G)

I installed the boot code like this:

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

And set the appropriate bootfs property on my ZFS pool:

zpool set bootfs=pool0/sys/freebsd pool0

Where pool0/sys/freebsd is my FreeBSD root filesystem (and contains, among other things, the /boot directory).