Re: can not boot from second disk after installation which computer use zfs and raid1

From: Edward Sanford Sutton, III <mirror176_at_hotmail.com>
Date: Mon, 16 Oct 2023 08:09:37 UTC
On 10/15/23 07:57, PstreeM China wrote:
> hello Expert:
> 
> It's glad to discuss with you.
> here is my issue:
> 
> I have an computer which has 2 sata ssd, and i install freebsd 13.2 in the
> computer.
> during the installation stage, i select to use zfs  and raid1, choice uefi
> as the boot support.
> 
> after the installation, test only the first disk
>   can be boot.
> only one bootable disk can be found in the bios's boot menu.
> if i remove the first disk, i can not boot into the
>   system.
> 
> try use the command gpart bootcode
>   to write the bootcode into the second disk, but not work.

   UEFI bootcode is not installed or updated with gpart. If you ran a 
command along the lines of "gpart bootcode -b /boot/pmbr -p 
/boot/gptzfsboot -i 1 ada1" but you are using UEFI booting then the step 
was wrong. That command would be appropriate for the older BIOS style of 
booting.

   If `gpt show` lists an EFI partition on one disk but not the other, 
than one disk has a partition to store /boot/loader.efi, which is what 
UEFI booting looks for, while the other disk does not. The partition is 
likely mounted as /boot/efi by default, but only one will be mounted. It 
is an msdos type of partition.

   If only one disk has that partition and the other does not and 
doesn't have room, then you would need to make room for it by deleting 
and recreating partitions accordingly. If RAID1=mirroring, you could 
delete the partition structure on one disk and recreate it to match the 
correct disk; this requires removing and replacing the vdev for zfs 
accordingly and it should sync up the data with a scrub process. If you 
have a swap partition on the disk without the boot partition, you could 
delete swap partition, make boot partition, and make swap out of the 
remaining space.

   In the future, you need to copy /boot/loader.efi to its appropriate 
location (likely /boot/efi/freebsd/loader.efi or 
/boot/efi/boot/bootx64.efi) and need to make sure it is copied to both 
disks. If you question its bootability, copy it to only 1 and force 
booting form that disk (disconnecting the drive if unsure how the BIOS 
responds no a failed bootcode load) and then copy it to the second disk 
after testing; zfs boot environments do not protect this data. Upgrading 
zfs pool/filesystem (a manual step not performed by freebsd-update) 
without doing so will likely leave the system unbootable until a new 
compatible bootloader is copied in.

   loader.efi(8) and uefi(8) seem to be documentation related to 
understanding this with the first even giving such upgrade instructions.

> google's result is also no help for this issue.
> launch this session to ask if someone face the same question or can give
> some solution to fix this. very thanks.
> 
> br/armin
>