Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 25 May 2025 13:14:05 +0200
From:      Roman Bogorodskiy <novel@freebsd.org>
To:        virtualization@freebsd.org
Subject:   bhyve: bootindex= not working?
Message-ID:  <aDL7fQR2nhjH_RmL@tulp>

next in thread | raw e-mail | index | archive | help

Hi,

I'm trying to understand how to use bootindex= configuration for disk
devices.

I start with a fresh copy of the VARs file:

sudo cp /usr/local/share/uefi-firmware/BHYVE_UEFI_VARS.fd /data/vars/freebsd_VARS.fd

Then start a VM:

sudo bhyve -c 2 -m 4096 -A -I -u -H -P \                                            
-s 0:0,hostbridge \
-l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd,/data/vars/freebsd_VARS.fd,fwcfg=qemu \
-s 2:0,xhci,tablet -s 1:0,lpc \
-s 3:0,ahci,hd:/data/img/freebsd.img,bootindex=1,cd:/data/isos/FreeBSD-14.2-RELEASE-amd64-disc1.iso,bootindex=2 \
-s 5:0,fbuf,tcp=127.0.0.1:5920 -l com1,/dev/nmdm5A \
freebsd

With this configuration I expect it to boot from the "hd" device. Instead, it boots into the installer.

In the installer I see:

# efibootmgr -v
Boot to FW : false
BootCurrent: 0001
Timeout    : 0 seconds
BootOrder  : 0000, 0001, 0002, 0003
 Boot0000* UiApp Fv(7cb8bdc9-f8eb-4f34-aaea-3ee4af6516a1)/FvFile(462caa21-7614-4503-836e-8ab6f4662331)
+Boot0001* UEFI BHYVE SATA DVD ROM BHYVE-6057-BC56-DB6C PciRoot(0x0)/Pci(0x3,0x0)/Sata(0x1,0xffff,0x0)
 Boot0002* UEFI BHYVE SATA DISK BHYVE-412B-5D46-BC34 PciRoot(0x0)/Pci(0x3,0x0)/Sata(0x0,0xffff,0x0)
 Boot0003* EFI Internal Shell Fv(7cb8bdc9-f8eb-4f34-aaea-3ee4af6516a1)/FvFile(7c04a583-9e3e-4f1c-ad65-e05268d0b4d1)


Unreferenced Variables:
#

I thought maybe it doesn't pay attention to bootindex= when the VARs
file is specified, so I tried like this:

sudo bhyve -c 2 -m 4096 -A -I -u -H -P \
-s 0:0,hostbridge \
-l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd,fwcfg=qemu \ 
-s 2:0,xhci,tablet -s 1:0,lpc \
-s 3:0,ahci,hd:/data/img/freebsd.img,bootindex=1,cd:/data/isos/FreeBSD-14.2-RELEASE-amd64-disc1.iso,bootindex=2 \
-s 5:0,fbuf,tcp=127.0.0.1:5920 -l com1,/dev/nmdm5A \
freebsd

Result is the same.

Also, instead of this:

-s 3:0,ahci,hd:/data/img/freebsd.img,bootindex=1,cd:/data/isos/FreeBSD-14.2-RELEASE-amd64-disc1.iso,bootindex=2 \

I've tried:

-s 3:0,ahci-hd,/data/img/freebsd.img,bootindex=1 -s 4:0,ahci-cd,/data/isos/FreeBSD-14.2-RELEASE-amd64-disc1.iso,bootindex=2 \

No difference.

No, going back to the very first command I used. In the installer's
shell, I execute:

# efibootmgr -o 0002
Boot to FW : false
BootCurrent: 0001
Timeout    : 0 seconds
BootOrder  : 0002
 Boot0002* UEFI BHYVE SATA DISK BHYVE-412B-5D46-BC34
#

And reboot. It boots from the disk now, according to the configuration:

root@freebsd:~ # efibootmgr -v
Boot to FW : false
BootCurrent: 0002
Timeout    : 0 seconds
BootOrder  : 0002, 0000, 0001, 0003
+Boot0002* UEFI BHYVE SATA DISK BHYVE-412B-5D46-BC34 PciRoot(0x0)/Pci(0x3,0x0)/Sata(0x0,0xffff,0x0)
 Boot0000* UiApp Fv(7cb8bdc9-f8eb-4f34-aaea-3ee4af6516a1)/FvFile(462caa21-7614-4503-836e-8ab6f4662331)
 Boot0001* UEFI BHYVE SATA DVD ROM BHYVE-6057-BC56-DB6C PciRoot(0x0)/Pci(0x3,0x0)/Sata(0x1,0xffff,0x0)
 Boot0003* EFI Internal Shell Fv(7cb8bdc9-f8eb-4f34-aaea-3ee4af6516a1)/FvFile(7c04a583-9e3e-4f1c-ad65-e05268d0b4d1)


Unreferenced Variables:
root@freebsd:~ #

Now, if I swap the bootindex= values to force to boot from the CD, it
also has no effect, from now on it'll be booting from the disk.

All in all, it looks like it stores boot options in the VARS file
properly, but completely ignores the bootindex command line
configuration.

Is it a bug somewhere or am I doing something wrong?

I'm running 15.0-CURRENT ~1 month old and edk2-bhyve-g202308_5.
Guest is FreeBSD 14.2-RELEASE.

Thanks,
Roman




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?aDL7fQR2nhjH_RmL>