[Bug 296701] [gptzfsboot] Doesn't boot if the root zpool is on another disk than the booting one

[email protected] Sat, 11 Jul 2026 16:59:32 +0000
Newsgroups gmane.os.freebsd.bugs
Message-ID <[email protected]/bugzilla/>
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=296701

            Bug ID: 296701
           Summary: [gptzfsboot] Doesn't boot if the root zpool is on
                    another disk than the booting one
           Product: Base System
           Version: 15.1-RELEASE
          Hardware: amd64
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: misc
          Assignee: [email protected]
          Reporter: [email protected]

The documentation of gptzfsboot states that it seeks for zfs pool on all disks,
starting by the booting one.

In fact, it is unable to boot if the root zpool is located on another disk than
the one that boots. I mean you get the boot prompt. You can actually boot, but
you have to type the name of the zfs pool followed by its active BE, i.e.
zfs:zroot/ROOT/default:/boot/zfsloader.

To reproduce: have a freebsd installation, add a disk, create a GPT scheme then
a freebsd-boot partition. Fill this last with gptzfsboot and install pmbr on
this very disk. Once done, poweroff, then exchange the boot order so the new
disk is first. You will get a boot prompt.

I looked into the source and found this in stand/i386/gptzfsboot/zfsboot.c from
releng/15.1, function i386_zfs_probe:

    for (dev.dd.d_unit = 0; bd_unit2bios(&dev) >= 0; dev.dd.d_unit++) {
        snprintf(devname, sizeof (devname), "%s%d:", bioshd.dv_name,
            dev.dd.d_unit);

        /* If this is not boot disk, use generic probe. */
        if (dev.dd.d_unit != boot_unit)
            zfs_probe_dev(devname, NULL, true);
        else
            zfs_probe_dev(devname, &pool_guid, true);

        if (pool_guid != 0 && bdev == NULL) {
            bdev = malloc(sizeof (struct i386_devdesc));
            bzero(bdev, sizeof (struct i386_devdesc));
            bdev->zfs.dd.d_dev = &zfs_dev;
            bdev->zfs.pool_guid = pool_guid;
        }
    }

What is this "generic probe"? It's obvious that if we are not on the boot disk,
the zpool won't be recorded in bdev var.

I removed this test to just call zfs_probe_dev(devname, &pool_guid, true) in
all cases and it works.

At this point, I didn't make a patch because I would like to know what is the
purpose of this generic probe. Seems to be related to the nextboot feature:
https://cgit.freebsd.org/src/commit/stand/i386/zfsboot/zfsboot.c?h=releng/15.1&id=3830659e99640001c09d26dfc0e1bbd77d919a62

I think it's a regression, but a very ancient one because older gptzfsboot
(probably from the 13 era) worked. See:
https://forums.freebsd.org/threads/loader-not-found-after-upgrading-the-bios-boot-loader-root-on-zfs-freebsd-boot-on-usb.103205/

-- 
You are receiving this mail because:
You are the assignee for the bug.