one birdy and a little guy and a bad mousie and a lion

FreeBSD 8 PXEBoot with Grub2

Posted Friday, January 15th 2010 @ 6:46PM

I just spent much longer on this than I care to admit. Hopefully this post will save someone else the time, until the dudes working on the grub2 project fill their documentation out.

Trying to PXEboot a recent FreeBSD environment using grub2pxe? All the docs out there for PXE+FreeBSD from early 2000 (or worse) and using BSD's 'pxeboot' binary? Can't find anything on the 'kfreebsd' magic of grub2?

Here's the magic sauce. Note that I compressed the kernel, so it'll be much faster under tftp.

menuentry "FreeBSD 8.0 x86" {
   echo "Fetching the kernel and UFS root."
   echo "This could take a few minutes, so hang tight... "

   kfreebsd /freebsd/x86_8.0/kernel/kernel.gz Dh
   kfreebsd_loadenv /freebsd/x86_8.0/device.hints
   kfreebsd_module /freebsd/x86_8.0/mfsroot.gz type=mfs_root
   set kFreeBSD.vfs.root.mountfrom=ufs:/dev/md0c

   echo "Aaaiiight!"
   sleep 2
}

So far, so good.

Comments

Michael Granger
Monday, January 18th 2010 @ 9:10AM

I love the magic 'Dh'! I spent the better part of a week trying to get this to work, and never found that bit. Glad you finally got it working!

Rowe
Thursday, April 15th 2010 @ 12:24AM

I'm watching you make stool...

Pinback
Thursday, August 19th 2010 @ 11:59AM

Grub2 link is broken. Time for me to build a PXE server.

Rick
Tuesday, May 1st 2012 @ 11:47AM

We have been doing something very similar to this. We chain grub2pxe to pxelinux and load a FreeBSD mfsroot install environment from there. We chose to check out grub2pxe because FreeBSD's pxeboot.bs appears to contain various bugs which we encountered.

Our mfsroot makes use of environment variables to complete the install including making use of various FreeBSD kernel variables including, but not limited to:

boot.nfsroot.server boot.netif.ip boot.netif.gateway dhcp.host-name dhcp.routers

We were able to identify that we could pass these values onto the FreeBSD environment using the grub.cfg file. They were done in the fashion below:

set kFreeBSD.boot.nfsroot.server=$pxe_default_server set kFreeBSD.boot.netif.ip=$net_pxe_ip set kFreeBSD.boot.netif.gateway=$pxe_default_gateway set kFreeBSD.dhcp.host-name=$net_pxe_hostname set kFreeBSD.dhcp.routers=$pxe_default_gateway

The unfortunate thing here is that we have yet been able to get pxe_default_gateway to be accurately populated. Also, there is a lack of a way to identify a netmask.

We were able to identify the grub2pxe variables from the grub2 manual at gnu.org.

I am hoping that in the coming months, I can write a white paper and/or blog post that describes our configuration so that others can use our experiences to help in their own environments. We have found that documentation on similar configurations is seriously lacking. Feel free to contact me at vmiller at hostileadmin dot com if you're interested in more information.

Mahlon
Friday, May 4th 2012 @ 7:45AM

Rick's got a followup blog post, you can find it here!

Leave a comment





archives

jabber status

subscribe

plan updates

  • Surprisingly enjoyable, quiet evening of martini imbibing and Lua hacking. (24 days ago)
  • PC Game manufacturers need to stop listing "mouse and keyboard" among the requirements. I think we all are pretty well aware. (over 1 month ago)
  • P.S. You suck, and if I catch you trying again I'm going to hobble you with my aluminum baseball bat. Instant karma redemption. (over 2 months ago)
  • Dear asshat that failed to break into my car: did you have to break BOTH of my locks? Are you even familiar with the concept of a tumbler? (over 2 months ago)
  • "Your Amazon.com order of 'BLACK FUN FOAM 9 X 12 ...' has shipped!" ... don't ask. (over 2 months ago)

recently bookmarked