Bug 255824 - Unattended install with UEFI and ZFS fails
Summary: Unattended install with UEFI and ZFS fails
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 13.0-STABLE
Hardware: amd64 Any
: --- Affects Some People
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
: 255081 (view as bug list)
Depends on:
Blocks:
 
Reported: 2021-05-12 19:58 UTC by Mark Huizer
Modified: 2021-05-28 13:45 UTC (History)
4 users (show)

See Also:


Attachments
Suggested patch for unattended install (686 bytes, patch)
2021-05-12 20:32 UTC, Mark Huizer
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Huizer 2021-05-12 19:58:22 UTC
In 13.0 extra logic is added to use /boot/efi to set the UEFI boot part using efibootmgr. When using ZFS, /boot/efi is never mounted, so the changes are done to /mnt on tmpfs, rendering the system unable to boot.

I did this on a VM under ESXI and in https://forums.freebsd.org/threads/unattended-install-on-freebsd13-with-zfs-efi.80296/ it was also checked using VirtualBox, but after further investigation, I think this is unrelated to the install environment, and it should break on any system trying to do unattended install using ZFS and UEFI (or BIOS+UEFI).

The initial part of installerconfig that I use:

export DISTRIBUTIONS="kernel.txz base.txz localinstall.txz"
export INTERFACES="vmx0 vmx1"
export ZFSBOOT_VDEV_TYPE=stripe
export ZFSBOOT_DISKS=da0
export ZFSBOOT_SWAP_SIZE=2g
export ZFSBOOT_CONFIRM_LAYOUT=0
export ZFSBOOT_SWAP_ENCRYPTION=YES
export ZFSBOOT_BOOT_TYPE="UEFI"
export nonInteractive="YES"
Comment 1 Mark Huizer 2021-05-12 20:02:44 UTC
What I did to get it working is edit /usr/libexec/bsdinstall/script on my install medium (coming from NFS, so very convenient):

near line 113 :
if [ "$ZFSBOOT_DISKS"] ; then
  bsdinstall zfsboot
  bsdinstall mount
....

near 169:

bsdinstall entropy
if [ "$ZFSBOOT_DISKS"]; then
  bsdinstall umount
  zpool export $ZFSBOOT_POOL_NAME
...

This is not a real patch. I have to recreate my install environment from the ISO, and it should contain something like " if [ "$ZFSBOOT_BOOT_TYPE" = "UEFI" -o "$ZFSBOOT_BOOT_TYPE" = "BOOT+UEFI" ]; then ... fi", but I'll see what I can do
Comment 2 Mark Huizer 2021-05-12 20:32:12 UTC
Created attachment 224888 [details]
Suggested patch for unattended install

This seems to fix it for me
Comment 3 commit-hook freebsd_committer freebsd_triage 2021-05-14 12:33:40 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=34766aa8cb514472c571f8b0e90e833833acef51

commit 34766aa8cb514472c571f8b0e90e833833acef51
Author:     Nathan Whitehorn <nwhitehorn@FreeBSD.org>
AuthorDate: 2021-05-14 12:30:41 +0000
Commit:     Nathan Whitehorn <nwhitehorn@FreeBSD.org>
CommitDate: 2021-05-14 12:30:41 +0000

    Fix scripted installs on EFI systems using ZFS root with zfsboot.

    Unlike attended installations, scripted installs did not mount non-ZFS
    partitions when ZFS root (via zfsboot) was selected. Since this included
    the ESP, the EFI loader was not installed. Copy logic from the
    attended-install path to make this work.

    PR:             255824, 255081
    MFC after:      1 week
    Obtained from:  Mark Huizer

 usr.sbin/bsdinstall/scripts/script | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
Comment 4 Nils Johannsen 2021-05-28 06:10:29 UTC
*** Bug 255081 has been marked as a duplicate of this bug. ***
Comment 5 Nathan Whitehorn freebsd_committer freebsd_triage 2021-05-28 13:44:52 UTC
Fix in and MFC'ed. Thanks for the detailed report and patch!
Comment 6 commit-hook freebsd_committer freebsd_triage 2021-05-28 13:45:00 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=4aaf6dd0a6b11accf34ca999465c34e29153680f

commit 4aaf6dd0a6b11accf34ca999465c34e29153680f
Author:     Nathan Whitehorn <nwhitehorn@FreeBSD.org>
AuthorDate: 2021-05-14 12:30:41 +0000
Commit:     Nathan Whitehorn <nwhitehorn@FreeBSD.org>
CommitDate: 2021-05-28 13:43:35 +0000

    Fix scripted installs on EFI systems using ZFS root with zfsboot.

    Unlike attended installations, scripted installs did not mount non-ZFS
    partitions when ZFS root (via zfsboot) was selected. Since this included
    the ESP, the EFI loader was not installed. Copy logic from the
    attended-install path to make this work.

    PR:             255824, 255081
    MFC after:      1 week
    Obtained from:  Mark Huizer

    (cherry picked from commit 34766aa8cb514472c571f8b0e90e833833acef51)

 usr.sbin/bsdinstall/scripts/script | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)