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

From: <bugzilla-noreply_at_freebsd.org>
Date: Sat, 06 May 2023 06:05:12 UTC

--- Comment #2 from Henryk Paluch <hpaluch@seznam.cz> ---
Additional details:

The original installation disklabel looks that way:
(the da0s1a was create by install using: gpart add  -i 1 -t freebsd-zfs -s
2147483648b "da0s1")

# /dev/da0s1:
8 partitions:
#          size     offset    fstype   [fsize bsize bps/cpg]
  a:    4194304          0       ZFS                    
  b:    4194304    4194304      swap                    
  c:   18874304          0    unused        0     0     # "raw" part, don't
  d:    4194304    8388608       ZFS                    

Please notice that da0s1 starts at 0 - so extreme care must be taken
to not overwrite disklabel on 2nd sector (byte offest from 512 to 1023).


Using development machine with 2nd disk and GDB I have found following
stacktrace (by putting breakpoint just at __sys_write):

reakpoint 1.2, _write () at _write.S:4
4       _write.S: No such file or directory.
(gdb) bt
#0  _write () at _write.S:4
#1  0x00000008011af1f6 in __thr_write (fd=6, buf=0x7fffffffb040, nbytes=4096)
    at /usr/src/lib/libthr/thread/thr_syscalls.c:618
#2  0x000000000104c900 in zero_label (path=path@entry=0x7fffffffc190
    at /usr/src/sys/contrib/openzfs/cmd/zpool/zpool_vdev.c:905
#3  0x000000000104b5f0 in make_disks (zhp=zhp@entry=0x0, nv=0x801c10420)
    at /usr/src/sys/contrib/openzfs/cmd/zpool/zpool_vdev.c:1048
#4  0x000000000104b333 in make_disks (zhp=zhp@entry=0x0,
    at /usr/src/sys/contrib/openzfs/cmd/zpool/zpool_vdev.c:1070
#5  0x000000000104b8e1 in make_root_vdev (zhp=0x6, zhp@entry=0x0,
props=<optimized out>, force=force@entry=1, 
    check_rep=<optimized out>, replacing=replacing@entry=B_FALSE,
dryrun=dryrun@entry=B_FALSE, argc=1, 
    argv=0x801c36040) at
#6  0x0000000001036ef9 in zpool_do_create (argc=<optimized out>,
argv=<optimized out>)
    at /usr/src/sys/contrib/openzfs/cmd/zpool/zpool_main.c:1587
#7  0x00000000010364b6 in main (argc=9, argv=0x7fffffffeb38)
    at /usr/src/sys/contrib/openzfs/cmd/zpool/zpool_main.c:10755

The problematic code is on 

#3  0x000000000104b5f0 in make_disks (zhp=zhp@entry=0x0, nv=0x801c10420)
    at /usr/src/sys/contrib/openzfs/cmd/zpool/zpool_vdev.c:1048

Which looks like:

                       ret = zero_label(udevpath);
                        if (ret)
                                return (ret);

Here is source pointer but the line offset is a bit different from what I see
in local sources of 13.2. release:

And this is problem - overwriting disklabel..

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