Reinstalling boot blocks on a ZFS-only system

Garrett Wollman wollman at hergotha.csail.mit.edu
Mon May 13 03:54:47 UTC 2013


In article <20130513032838.GA76253 at icarus.home.lan>, jdc at koitsu.org write:
>https://wiki.freebsd.org/RootOnZFS/GPTZFSBoot
>
>5. Install the Protected MBR (pmbr) and gptzfsboot loader

Bug #1: "Protective", not "Protected".

>   Fixit# gpart bootcode -b /mnt2/boot/pmbr -p /mnt2/boot/gptzfsboot -i 1 ad0
>
>   This may fail with an "operation not permitted" error message, since the
>   kernel likes to protect critical parts of the disk. If this happens for
>   you, run:
>
>   Fixit# sysctl kern.geom.debugflags=0x10

I suppose the bit that's missing here is:

	...and then file a bug report, with severity "serious" and
	priority "high", because this indicates that something is
	seriously broken in the kernel's implementation of GPT
	partitioning.

The only way this step can fail (absent bugs) is if something (other
than gpart) has either the whole-disk device or the partition 1 device
open in exclusive mode, which is a "can't happen" condition at this
stage in an installation.  (Well, it can happen if the disk you are in
the process of destroying has a still-mounted filesystem on it, which
is what the code is supposed to prevent!)

This little bit of cargo-culting used to be necessary for *MBR* and
*bsdlabel* partitioning, before the days of "gpart bootcode", to
update the boot0 and embedded partition-boot (boot1) blocks while the
filesystem was mounted, because the bsdlabel boot blocks are stored in
the first 64k of the root filesystem.  When using GPT, the boot blocks
are stored in the boot partition, which doesn't have a mountable
filesystem on it, so should never be open for write except when gpart
bootcode is doing the deed.

-GAWollman



More information about the freebsd-stable mailing list