3

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.

larsks
  • 41,276
  • 13
  • 117
  • 170
  • What version are you running. I know 8.1 and prior can not boot from ZFS without fairly extensive hacking. I can't remember off the top of my head if 8.2 has boot support; I believe 9-Current does and I know it will be backported to either 8.2 or 8.3. – Chris S Jan 28 '11 at 14:32
  • Booting from ZFS is relatively easy (that's what I meant when I said that `/boot` can reside on ZFS without a problem). I just need somewhere to the `gptzfsboot` code, which right now is on a `freebsd-boot` partition on a CF card. – larsks Jan 28 '11 at 17:24

2 Answers2

6

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).

larsks
  • 41,276
  • 13
  • 117
  • 170
1

It looks like it is possible to boot from ZFS pool created from whole-disk devices.

Just install zfsboot according to zfsboot man page:

zfsboot is typically installed using dd(1). To install zfsboot on the ada0 drive:

 dd if=/boot/zfsboot of=/dev/ada0 count=1
 dd if=/boot/zfsboot of=/dev/ada0 iseek=1 oseek=1024

The Section 1.4: Boot Block of the ZFS specification says that 3.5MB of reserved space is at this position. This explains why the 64k of zfsboot fit in there without bothering the filesystem.

I haven't personally tried it yet.

Sources:

Marián Černý
  • 222
  • 2
  • 7