One of the drives in boot-pool failed and needed replacement. Unfortunately, I mis-clicked in TrueNAS UI and accidentally detached the failed drive instead of replacing it. With a new drive in, here is what I did:

The pool was not healthy:

root@storedge01[~]# zpool status boot-pool
config:

        NAME        STATE     READ WRITE CKSUM
        boot-pool   DEGRADED     0     0     0
          mirror-0  DEGRADED     0     0     0
            da0p2   ONLINE       0     0     0
            da1p2   FAULTED      0     3     0

First let’s get current partitioning:

root@storedge01[/tmp]# gpart show
=>      40  30031792  da0  GPT  (14G)
        40      1024    1  freebsd-boot  (512K)
      1064  30030768    2  freebsd-zfs  (14G)

=>      40  30080944  da1  GPT  (14G) [CORRUPT]
        40      1024    1  freebsd-boot  (512K)
      1064  30079920    2  freebsd-zfs  (14G)

Recreate partitions:

root@storedge01[/tmp]# gpart destroy -F /dev/da1
da1 destroyed
root@storedge01[/tmp]# gpart create -s gpt /dev/da1
da1 created
root@storedge01[/tmp]# gpart show
=>      40  30031792  da0  GPT  (14G)
        40      1024    1  freebsd-boot  (512K)
      1064  30030768    2  freebsd-zfs  (14G)

=>      40  30080944  da1  GPT  (14G)
        40  30080944       - free -  (14G)
root@storedge01[/tmp]# gpart add -t freebsd-boot -s 512K /dev/da1
da1p1 added
root@storedge01[/tmp]# gpart add -t freebsd-zfs -s 30079920 /dev/da1
da1p2 added

Let’s recheck:

root@storedge01[/tmp]# gpart show
=>      40  30031792  da0  GPT  (14G)
        40      1024    1  freebsd-boot  (512K)
      1064  30030768    2  freebsd-zfs  (14G)

=>      40  30080944  da1  GPT  (14G)
        40      1024    1  freebsd-boot  (512K)
      1064  30079920    2  freebsd-zfs  (14G)

Install bootcode:

root@storedge01[/tmp]# gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 /dev/da1
partcode written to da1p1
bootcode written to da1

For some reason, re-attaching always failed unless ashift parameter was specified, which is basically blocksize:

root@storedge01[/tmp]# zpool attach -f -o ashift=9 boot-pool da0p2 da1p2

Value of ashift can found in zdb output:

root@storedge01[~]# zdb -C boot-pool | grep ashift
                ashift: 9

After the new disk was attached, system resilvered the pool.