[Bug 271262] bsdinstaller in AutoZFS + MBR mode always wipes disklabel - rendering system non-bootable

From: <bugzilla-noreply_at_freebsd.org>
Date: Fri, 05 May 2023 16:29:05 UTC

            Bug ID: 271262
           Summary: bsdinstaller in AutoZFS + MBR mode always wipes
                    disklabel - rendering system non-bootable
           Product: Base System
           Version: 13.2-RELEASE
          Hardware: amd64
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: hpaluch@seznam.cz

Created attachment 241996
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=241996&action=edit
Installation log for AutoZFS on MBR layout that will destroy disklabel

While trying several time this installation:
- FreeBSD-13.2-RELEASE-amd64-disc1.iso

When I select this layout:
- AutoZFS

It always ends up in broken - Non-bootable system (famous error "Missing
operating system"

Analysis of such system (booting CD in Shell mode) has shown that somehow whole
disklabel is missing.
Only primary FreeBSD partition exists.

I traced down the problem that this command (from bsdinstall_log):

# this works
disklabel da0s1
# this command wipes 1st 4KB of da0s1a thus destroying disklabel!
zpool create -o altroot=/mnt  -m "/bootpool" -f "bootpool"   da0s1a
# the command below will now end with error!
disklabel da0s1

Tracing above "zpool create" command I have found that it really wipes
1st 4KB of "da0s1a" thus destroying disklabel that occupies offset from 512 to
1024 bytes.

Here is relevant excerpt from truss tracing:

  702: fstatat(AT_FDCWD,"/dev/da0s1a",{ mode=crw-r-----
,inode=104,size=0,blksize=4096 },0x0) = 0 (0x0)
  702: openat(AT_FDCWD,"/dev/da0s1a",O_WRONLY|O_EXCL,00) = 6 (0x6)
  702: write(6,"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"...,4096) = 4096 (0x1000)
  702: fdatasync(6)                              = 0 (0x0)
  702: close(6)                                  = 0 (0x0)
  702: open("/mnt/bootpool",O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC,015)
ERR#2 'No such file or directory'

You can clearly see that device da0s1a is opened and immediately wiped with
4096 bytes of zeroes thus liquidating disklabel (!).

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