Reinstalling boot blocks on a ZFS-only system

Jeremy Chadwick jdc at koitsu.org
Mon May 13 03:28:40 UTC 2013


On Sun, May 12, 2013 at 11:14:20PM -0400, Garrett Wollman wrote:
> In article <20130512205837.GA69605 at icarus.home.lan>, jdc at koitsu.org writes:
> 
> >You may also need to set kern.geom.debugflags=0x10 to inhibit GEOM's
> >"safety measure" / to permit writing to LBA 0; see GEOM(4) and search
> >for the word "foot".
> 
> If you have set up your partitioning properly (read: following the
> clearly recommended best practice on the wiki), there should never,
> ever be any reason to do this.  (That is why it's called a DEBUG
> flag.) ...

I'm in full agreement with you, but the irony is that you refer to "the
wiki", which I have intentionally ignored for years now because it's
always wrong/always out of date/under scrutiny/do-not-care-to-debate.
Case in point:

https://wiki.freebsd.org/RootOnZFS/GPTZFSBoot

5. Install the Protected MBR (pmbr) and gptzfsboot loader

   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

https://wiki.freebsd.org/RootOnZFS/GPTZFSBoot/Mirror

5. Install the Protected MBR (pmbr) and gptzfsboot loader to both drives

   Fixit# gpart bootcode -b /mnt2/boot/pmbr -p /mnt2/boot/gptzfsboot -i 1 ad0
   Fixit# gpart bootcode -b /mnt2/boot/pmbr -p /mnt2/boot/gptzfsboot -i 1 ad1

   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

https://wiki.freebsd.org/RootOnZFS/ZFSBootPartition

10. Install ZFS boot

    ...

    Install the boot1 stage:

    Fixit# dd if=/mnt2/boot/zfsboot of=/dev/ad0s3 count=1

   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

> The necessary and sufficient invocation is:
> 
> # gpart bootcode -b /boot/pmbr -p /boot/gptzfsloader -i 1 [a]daX
> 
> I have no idea how this works with MBR partitioning, but I would make
> one suggestion in that regard: DON'T.  Whatever makes you think you
> want to do that, think harder and find another way.

I believe for MBR you'd need to refer to the slice, not the disk, i.e.
ada0s1 (NOT THE PARTITION ada0s1a).  I found this out long ago when
doing the classic "bsdlabel -B ada0" method of updating boot blocks only
to find it bitch/complain and insist I use the slice.

I haven't dared touch gpart for bootblock updates on any FreeBSD system
I have access to, simply because the gpart syntax is long and could
really screw you over if you make a typo.  Plus, remembering which files
to refer to in /boot is always spotty.  "Uh, do I use -b here or -p...
Uh, do I use /boot/mbr or /boot/pmbr... err...".  /boot is such a mess
these days.

-- 
| Jeremy Chadwick                                   jdc at koitsu.org |
| UNIX Systems Administrator                http://jdc.koitsu.org/ |
| Mountain View, CA, US                                            |
| Making life hard for others since 1977.             PGP 4BD6C0CB |


More information about the freebsd-stable mailing list