Bug 255081 - bsdinstall script installerconfig - does not install efi loader
Summary: bsdinstall script installerconfig - does not install efi loader
Status: Closed DUPLICATE of bug 255824
Alias: None
Product: Base System
Classification: Unclassified
Component: misc (show other bugs)
Version: 13.0-STABLE
Hardware: amd64 Any
: --- Affects Some People
Assignee: freebsd-sysinstall (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-04-15 08:01 UTC by Nils Johannsen
Modified: 2021-05-28 13:45 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nils Johannsen 2021-04-15 08:01:49 UTC
I have downloaded the memstick (link below), dd it to a usb stick, added the `installerconfig` (see below) to `/etc/installerconfig` and tried to install FreeBSD 13.0-RELEASE automatically to a PC. After rebooting the system came not up, because the `efi` partition should be created by `bsdinstall` was empty and did not include the `bootx64.efi`. After mounting the `efi` partition, creating the directory and copied the `/boot/loader.efi` to `/efi/boot/bootx64.efi` the new installed system booted up.

After `mount -u -rw /`, adding some `f_dprintf` to `/usr/libexec/bsdinstall/bootconfig` and a manual installation with `bsdinstall script /root/installerconfig | tee /root/installer.log` it generates this log:
- https://gitlab.com/-/snippets/2105237

This log indicates me, that the `efi` partition is not mounted while the `bootconfig` script tries to copy the `loader` to it... see below the extract from the `installer.log`.

MemStick:
- https://download.freebsd.org/ftp/releases/amd64/amd64/ISO-IMAGES/13.0/FreeBSD-13.0-RELEASE-amd64-memstick.img

installerconfig:
```
export nonInteractive="YES"
export ZFSBOOT_DISKS=ada0
DISTRIBUTIONS="kernel.txz base.txz"

#!/bin/sh
# see `man bsdinstall`
sysrc ifconfig_DEFAULT=DHCP
sysrc sshd_enable=YES
```

installer.log:
```
DEBUG: Running installation step: bootconfig
DEBUG: dialog.subr: DEBUG_SELF_INITIALIZE=[]
DEBUG: UNAME_S=[FreeBSD] UNAME_P=[amd64] UNAME_R=[13.0-RELEASE]
DEBUG: common.subr: Successfully loaded.
DEBUG:  uname -m => amd64
DEBUG:  mount => /dev/ufs/FreeBSD_Install on / (ufs, local) devfs on /dev (devfs) tmpfs on /tmp (tmpfs, local) tmpfs on /var (tmpfs, local) zroot/ROOT/default on /mnt (zfs, local, noatime, nfsv4acls) zroot/tmp on /mnt/tmp (zfs, local, noatime, nosuid, nfsv4acls) zroot/usr/home on /mnt/usr/home (zfs, local, noatime, nfsv4acls) zroot/usr/ports on /mnt/usr/ports (zfs, local, noatime, nosuid, nfsv4acls) zroot/usr/src on /mnt/usr/src (zfs, local, noatime, nfsv4acls) zroot/var/audit on /mnt/var/audit (zfs, local, noatime, noexec, nosuid, nfsv4acls) zroot/var/crash on /mnt/var/crash (zfs, local, noatime, noexec, nosuid, nfsv4acls) zroot/var/log on /mnt/var/log (zfs, local, noatime, noexec, nosuid, nfsv4acls) zroot/var/mail on /mnt/var/mail (zfs, local, nfsv4acls) zroot/var/tmp on /mnt/var/tmp (zfs, local, noatime, nosuid, nfsv4acls) zroot on /mnt/zroot (zfs, local, noatime, nfsv4acls)
DEBUG: Installing loader.efi onto ESP
DEBUG:  mkdir -p "/mnt/boot/efi//efi/freebsd" "/mnt/boot/efi//efi/boot"
DEBUG:  cp "/mnt/boot/loader.efi" "/mnt/boot/efi//efi/freebsd/loader.efi"
DEBUG: Creating UEFI boot entry
DEBUG:  efibootmgr --create --activate --label "FreeBSD" --loader "/mnt/boot/efi//efi/freebsd/loader.efi"
DEBUG: Finished configuring ESP
```

Regards from Lübeck, Nils

See also:
- https://lists.freebsd.org/pipermail/freebsd-stable/2021-April/093543.html
Reproduced on:
- https://bsd-hardware.info/?probe=25df932cdf
- https://bsd-hardware.info/?probe=ab8247d8b5
Comment 1 Nils Johannsen 2021-04-15 08:04:57 UTC
On 12.2-RELEASE this installerconfig works well.
- In 12.2 the efi loader is handled in bsdinstall/zfsboot
- In 13.0 the efi loader is handled in bsdinstall/bootconfig
Comment 2 Mark Huizer 2021-05-13 15:22:52 UTC
I think this is the same as bug #255824 . And I've added a possible patch there
Comment 3 commit-hook freebsd_committer 2021-05-14 12:33:41 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:09:56 UTC
Successfully tested with FreeBSD-13.0-STABLE-amd64-20210527-024a9aa7010-245691-memstick.img.
Comment 5 Nils Johannsen 2021-05-28 06:10:29 UTC

*** This bug has been marked as a duplicate of bug 255824 ***
Comment 6 commit-hook freebsd_committer 2021-05-28 13:45:01 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(-)