Slight tweak to allow md.c to be compiled when MD_IMAGE_SIZE isn't
defined.
Sponsored by: Netflix
Differential D59415
loader: Allow this to compile w/o MD_IMAGE_SIZE defined Authored by imp on Fri, Sep 4, 6:53 PM. Tags None Referenced Files
Subscribers
Details
Diff Detail
Event TimelineComment Actions Working great! First a simple shell script (requiere qemu and ipxe firmwares): #!/bin/sh # Boot a stock FreeBSD memstick over the network using the D59415..D59421 # loader # # The patched loader.efi speaks iPXE's download protocol itself: iPXE only # chainloads it, and the loader then fetches the memstick straight into RAM, # registers it, and boots. Nothing is typed at the loader prompt. # # Both files are fetched over HTTPS from their public homes; the memstick is # the stock published snapshot, unmodified. # Requirements: # - qemu # - ipxe set -eu loader=https://people.freebsd.org/~olivier/iPXE/loader.D59415.efi snap=FreeBSD-16.0-CURRENT-amd64-20260824-74019bc3ea91-288532 image=https://download.freebsd.org/ftp/snapshots/ISO-IMAGES/16.0/$snap-mini-memstick.img.xz arch=x86_64 mem=8G # the image lives in RAM; 726MB plus headroom workdir=$(mktemp -d /tmp/d59415.XXXXXX) trap 'rm -rf "$workdir"' EXIT INT TERM # iPXE hardcodes "file:autoexec.ipxe", so this must keep that exact name. # memdisk= is for a disk image (a memstick); an ISO would use memcd=. cat > "$workdir/autoexec.ipxe" <<EOF #!ipxe dhcp echo === chainloading patched loader.efi === chain $loader memdisk=$image echo Boot failed, press a key prompt EOF cp /usr/local/share/ipxe/ipxe.efi-${arch} "$workdir/ipxe.efi" for f in /usr/local/share/qemu/edk2-${arch}-code.fd \ /usr/local/share/edk2-qemu/QEMU_UEFI_CODE-${arch}.fd do [ -f "$f" ] && { efi=$f; break; }; done for v in /usr/local/share/qemu/edk2-i386-vars.fd \ /usr/local/share/edk2-qemu/QEMU_UEFI_VARS-${arch}.fd do [ -f "$v" ] && { varstpl=$v; break; }; done cp "$varstpl" "$workdir/vars.fd"; chmod u+w "$workdir/vars.fd" # -device virtio-rng-pci is REQUIRED: the TLS-enabled EDK2 network stack # blocks on entropy and never sends DHCP without it. SLIRP gives the guest # working outbound NAT, which is what reaches people.freebsd.org. exec qemu-system-${arch} -m $mem -boot n \ -drive if=pflash,unit=0,readonly=on,format=raw,file="$efi" \ -drive if=pflash,unit=1,format=raw,file="$workdir/vars.fd" \ -netdev user,id=net0,tftp="$workdir",bootfile=ipxe.efi \ -device virtio-net-pci,netdev=net0 \ -device virtio-rng-pci \ -display none -serial mon:stdio Then run it: $ ./boot.sh >>Start PXE over IPv4. Station IP address is 10.0.2.15 Server IP address is 10.0.2.2 NBP filename is ipxe.efi NBP filesize is 1170432 Bytes Downloading NBP file... NBP file downloaded successfully. BdsDxe: loading Boot0001 "UEFI PXEv4 (MAC:525400123456)" from PciRoot(0x0)/Pci(0x3,0x0)/MAC(525400123456,0x1)/IP v4(0.0.0.0,0x0,DHCP,0.0.0.0,0.0.0.0,0.0.0.0) BdsDxe: starting Boot0001 "UEFI PXEv4 (MAC:525400123456)" from PciRoot(0x0)/Pci(0x3,0x0)/MAC(525400123456,0x1)/I Pv4(0.0.0.0,0x0,DHCP,0.0.0.0,0.0.0.0,0.0.0.0) iiPPXXEE iinniittiiaalliissiinngg ddeevviicceess...... aauuttooeexxeecc..iippxxee...... ookk Consoles: EFI console Downloading https://download.freebsd.org/ftp/snapshots/ISO-IMAGES/16.0/FreeBSD-16.0-CURRENT-amd64-20260824-74019bc3ea91-288532-mini-memstick.img.xz as a disk We know we will download 126731440 bytes Staritng the download xz 126MB / 126MB (99%) Downloaded 126731440 bytes, actual size 726782464 -- registering ramdisk Installed RAM disk as VirtualDisk(0x6C2CF000,0x977EC1FF,0) Reading loader env vars from /efi/freebsd/loader.env FreeBSD/amd64 EFI loader, Revision 3.0 (Fri Sep 4 21:52:44 CEST 2026 olivier@bigone) Command line arguments: loader.D59415.efi memdisk=https://download.freebsd.org/ftp/snapshots/ISO-IMAGES/16.0/ FreeBSD-16.0-CURRENT-amd64-20260824-74019bc3ea91-288532-mini-memstick.img.xz Image base: 0xbd962000 EFI version: 2.70 EFI Firmware: EDK II (rev 1.00) Console: efi (0x20001000) Load Path: loader.D59415.efi Load Device: PciRoot(0x0)/Pci(0x3,0x0)/MAC(525400123456,0x1)/Uri(https://people.freebsd.org/~olivier/iPXE/loa der.D59415.efi) Ignoring UEFI boot manager Trying uefi_rootdev VirtualDisk(0x6C2CF000,0x977EC1FF,0) Trying: VirtualDisk(0x6C2CF000,0x977EC1FF,0) Setting currdev to disk0: Loading /boot/defaults/loader.conf Loading /boot/defaults/loader.conf Loading /boot/device.hints Loading /boot/loader.conf Loading /boot/loader.conf.d/rtw88.conf Loading /boot/loader.conf.local - - \ _____ ____ ____ ____ ___ _ _ _ | ___| __ ___ ___| __ ) ___|| _ \ |_ _|_ __ ___| |_ __ _| | | ___ _ __ | |_ | '__/ _ \/ _ \ _ \___ \| | | | | || '_ \/ __| __/ _` | | |/ _ \ '__| | _|| | | __/ __/ |_) |__) | |_| | | || | | \__ \ || (_| | | | __/ | |_| |_| \___|\___|____/____/|____/ |___|_| |_|___/\__\__,_|_|_|\___|_| ╔════════ Welcome to FreeBSD ══════════╗ ``` ` ║ ║ s` `.....---.......--.``` -/ ║ 1. Boot Installer [Enter] ║ +o .--` /y:` +. ║ 2. Boot Single user ║ yo`:. :o `+- ║ 3. Escape to loader prompt ║ y/ -/` -o/ ║ 4. Reboot ║ .- ::/sy+:. ║ 5. Cons: Dual (Serial primary) ║ / `-- / ║ ║ `: :` ║ Kernel: ║ `: :` ║ 6. kernel (1 of 1) ║ / / ║ ║ .- -. ║ Options: ║ -- -. ║ 7. Boot Options ║ `:` `:` ║ ║ .-- `--. ╚══════════════════════════════════════╝ .---.....----.| Loading kernel... /boot/kernel/kernel text=0x19cb20 text=0xf1930c text=0x4cffd7 data=0x180+0xe80 data=0x1b2f68+0x44d098 0x8+0x1b70 08+0x8+0x1814af (etc.) Starting primary installer on ttyu0 Welcome to FreeBSD! Please choose the appropriate terminal type for your system. Common console types are: ansi Standard ANSI terminal vt100 VT100 or compatible terminal xterm xterm terminal emulator (or compatible) Console type [vt100]: |