Solved boot FreeBSD bootloader (not base system) from iPXE

Hello
Is it possible to use /boot/pxeloader to _boot_ (not install) a existing FreeBSD installation in a hard drive?
I do not have a bootloader installed in my machine, so booting /boot/pxeloader to boot the install is useful. I've copied the /boot directory I need to the root of my tftp server so it can load, then in iPXE i run:

Code:
set root-path tftp://192.168.1.157/
chain tftp://192.168.1.157/boot/pxeboot dhcp.root-path=tftp://192.168.1.157/
But it gets stucks in here:
2025-03-29-135047_736x274_scrot.png


(note that I'm using qemu to test this. not real hardware)

What is failing to load? How do I know that it is respecting the specified "root-path"? I've read somewhere that apparently pxeboot(8) does NOT use the iPXE root-path

So what's the deal, do I have to set up an entire freebsd root to boot from NFS? Do I have to use DHCP to set the root path instead of iPXE? I do not want to set up a hole FreeBSD root in NFS, i do not want to boot from network, I only want to load the /boot directory from kernel,as the root FS is in an SD card.

I cannot try this in my hardware, because this is BIOS only, and my machine is UEFI, also I cannot make qemu use my LAN in which I have the actual DHCP server I can configure.

Thanks
 
Interesting, thanks for your feedback

If it helps, I've managed before to do what I want to do (load the ONLY the bootloader from iPXE) doing the following:

1. Get a freebsd iso that boots
2. Unpackage it
3. Remove everything but the /boot directory
3.1. copy your /boot/loader.rc and /boot/loader.conf (maybe /boot/kernel if you want) to the root of the unpackaged iso file (so you can have the "Boot multiuser option" instead of the "Install FreeBSD"
4. mkisofs -D -R -b boot/cdboot -allow-leading-dots -no-emul-boot -o boot2.iso workbsd
5. Verify that iso works, by using qemu or something
6. Upload the boot2.iso file to the root of an http/tftp server
7. in iPXE, just run sanboot http://x.x.x.x/boot2.iso
FreeBSD bootloader should appear and boot

But this is not what I want to do. Despite it "Just Works™" I can tell the correct way to do this is using the /boot/pxeboot file. Not a hacked ISO crafted by mkisofs.

I am experimenting with customs kernels recently, so it would be better just to install the new kernel in the root of tftp or nfs instead of having to make a whole new .iso!
 
I use FreeBSD with iPXE, but for this it is necessary to convert the official FreeBSD ISO to 'mfsbsd' mode (archive FS as mfsroot image), because the FreeBSD loader has quite a lot of different limitations.
 
Thanks for the resources msplsh. The problem is not boot2.iso. boot2.iso works perfectly. What doesn't work is /boot/pxeboot

The hacked ISO is about 120MBs in total. And works well, but I simply want to see if /boot/pxeboot is better in some way because seems to be the intended way to do what I want, and simplifies installing kernels and updating the /boot directory (i don't have to rebuild the ISO every time)
 
What am I doing wrong?
dhcp server configuration:
Code:
subnet 192.168.1.0 netmask 255.255.255.0 {

  range 192.168.1.2 192.168.1.99;

  option routers 192.168.1.1;

  next-server 192.168.1.157;


  if exists user-class and option user-class = "FreeBSD" {

         option root-path "tftp://192.168.1.157/freebsd_boot";

   }

  if exists user-class and option user-class = "iPXE" {

      filename "http://192.168.1.207/boot.ipxe"; # iPXE script

  } elsif option client-architecture = 00:00 {

      filename "pxeboot"; # FreeBSD's /boot/pxeboot

  } else {

      filename "ipxe.efi"; # iPXE for EFI systems

  }

}


The "freebsd_boot" directory in the tftp server roots looks like this:

Code:
root@generic:/usr/local/tftp/freebsd_boot # ls
boot
root@generic:/usr/local/tftp/freebsd_boot # ls boot
beastie.4th             color.4th               gptzfsboot              loader.help.userboot    lua                     shortcuts.4th
boot                    defaults                images                  loader.rc               mbr                     support.4th
boot0                   delay.4th               isoboot                 loader_4th              menu-commands.4th       uboot
boot0sio                device.hints            kernel                  loader_lua              menu.4th                userboot.so
boot1                   dtb                     loader                  loader_simp             menu.rc                 userboot_4th.so
boot2                   efi.4th                 loader.4th              logo-beastie.4th        menusets.4th            userboot_lua.so
brand-fbsd.4th          firmware                loader.conf             logo-beastiebw.4th      modules                 version.4th
brand.4th               fonts                   loader.conf.d           logo-fbsdbw.4th         pmbr                    zfs
cdboot                  frames.4th              loader.conf~            logo-orb.4th            pxeboot                 zfsboot
check-password.4th      gptboot                 loader.help.bios        logo-orbbw.4th          screen.4th              zfsloader

>Note that pxeboot expects to fetch /boot/loader.rc from the specified
server before loading any other files.
--- pxeboot(8)

I have the required files too

Code:
root@generic:/usr/local/tftp/freebsd_boot # file boot/loader.conf
boot/loader.conf: ASCII text
root@generic:/usr/local/tftp/freebsd_boot # file boot/loader.rc
boot/loader.rc: ASCII text
root@generic:/usr/local/tftp/freebsd_boot #
 
The
filename "pxeboot";
and then hanging at that place where your screenshot is at is indeed what I am seeing.

The annoying thing is that it suddenly broke and old versions of the pxeboot binary (which significantly changed) also broke at the same time. Something about my environment, maybe even the Ethernet.

If you want I can provide a bunch of different "pxeboot" binaries for you to test. I find it surprising to see the apparently same hang in a VM.
 
Of course cracauer. I'd be glad to help discover which pxeboot binary works, I'll wait for the binaries. Thanks!
 
Thank you cracauer, I will try them. I think I've made some progress:
Note: I'm no longer trying this in a VM because seems to be working better on real hardware that can connect to my DHCP server. I ditched tftp after reading in diskless(8) that tftp support in pxeboot(8) is a compile-time feature (i recompiled it with tftp, but at this point i'm using nfs because i made progress with it)

Do not worry about zfs warnings: I am using openzfs 2.3.0 because I had to expand a raidz. I have the modules, so should Just Work™
2025-03-29-174146_1029x700_scrot.png

dhcp configuration:
Code:
subnet 192.168.1.0 netmask 255.255.255.0 {
  range 192.168.1.2 192.168.1.99;
  option routers 192.168.1.1;
  next-server 192.168.1.157;

  if exists user-class and option user-class = "FreeBSD" {
         option root-path "nfs://192.168.1.157/usr/local/tftp/freebsd_boot";
   }

  if exists user-class and option user-class = "iPXE" {
      filename "http://192.168.1.207/boot.ipxe";
  } elsif option client-architecture = 00:00 {
      filename "pxeboot";
  } else {
      filename "ipxe.efi";
  }

}

/etc/exports:
Code:
/usr/local/tftp -maproot=root -network 192.168.1.0 -mask 255.255.255.0
I think the error is the nfs root path. (I tried setting root-path to nfs://192.168.1.157/freebsd_boot, didn't work, set it to the current option. not working either.

Mounting the remote file system works:
Code:
~ [qmdx] % doas mount_nfs -o nfsv3 192.168.1.157:/usr/local/tftp boot3
~ [qmdx] % ls boot3
boot.iso      ipxe      netboot.xyz.efi   pxeboot     undionly.kpxe
freebsd_boot  ipxe.efi  netboot.xyz.kpxe  splash.png
 
The root-path points to a NFS directory (not file) that has /boot/ in it.

Here is what I use:
Code:
    option root-path "172.18.30.2:/dlv4/freebsd-current-root1";
 
Got it working with NFS and the following DHCP configuration :)
Code:
option root-path "192.168.1.157:/usr/local/tftp/freebsd_boot";
I got confused at that part, because the pxeboot(8) manpage mentions nothing about colons in the syntax of root-path:
Code:
Valid option root-path syntax is    the following

       /path           path    to the root filesystem on the NFS server

ip://path path to the root filesystem on the NFS server ip

       nfs://path       path    to the root filesystem on the NFS server

nfs://ip/path path to the root filesystem on the NFS server ip

       tftp://path       path    to the root filesystem on the TFTP server

tftp://ip/path path to the root filesystem on the TFTP server ip
Maybe I should send a patch for that manpage

Thank you very much, cracauer

P.S. After booting this, I realized my hacker iso is faster than this, probably because the NFS server is in a raspi which is limited to 100mbps. I'll have to change the nfs server to a gigabit connection
2025-03-29-180927_1013x678_scrot.png
 
Back
Top