churchers / vm-bhyve

Shell based, minimal dependency bhyve manager
BSD 2-Clause "Simplified" License
821 stars 174 forks source link

Feature request: pxe netboot #246

Open zachfi opened 5 years ago

zachfi commented 5 years ago

For an environment with a robust PXE installation for hardware, reusing that infrastructure is appealing. Perhaps someone has an example with ipxe or something similar?

munixsoft commented 5 years ago

+1 for this feature. This should work. I did not find anything on the bhyve manual page but it definitely works: https://forums.freebsd.org/threads/bhyve-network-booting.62396/

churchers commented 5 years ago

Looks like this might be possible using a rEFInd boot disk. If so, then it may be possible without any changes to vm-bhyve, or maybe just a simple "pxe" option that boots into rEFInd.

Interesting, but I don't have any pxe infrastructure, so the primary issue would be getting something running that I could test with, and getting up to speed on using pxe in the first place...

zachfi commented 5 years ago

I've installed the ipxe port, loaded the ipxe.iso into the vm-bhyve cache, and added the following line to the vm config. grub_install0="linux16 /ipxe.krn". I thought this would get me close, but I just get a crash. Here is the output.

Nov 24 16:14:34: initialising
Nov 24 16:14:34:  [loader: grub]
Nov 24 16:14:34:  [uefi: no]
Nov 24 16:14:34:  [cpu: 1]
Nov 24 16:14:34:  [memory: 512M]
Nov 24 16:14:34:  [hostbridge: standard]
Nov 24 16:14:34:  [com ports: com1]
Nov 24 16:14:34:  [uuid: 054fe809-f046-11e8-b345-bcee7bdf934c]
Nov 24 16:14:34:  [utctime: yes]
Nov 24 16:14:34:  [debug mode: yes]
Nov 24 16:14:34:  [primary disk: disk0.img]
Nov 24 16:14:34:  [primary disk dev: file]
Nov 24 16:14:34: initialising network device tap0
Nov 24 16:14:34: failed to find virtual switch 'public'
Nov 24 16:14:34: booting
Nov 24 16:14:34: create file /aux/vm/pxe/device.map
Nov 24 16:14:34:  -> (cd0) /aux/vm/.iso/ipxe.iso
Nov 24 16:14:34:  -> (hd0) /aux/vm/pxe/disk0.img
Nov 24 16:14:34: create file /aux/vm/pxe/grub.cfg
Nov 24 16:14:34:  -> timeout=3
Nov 24 16:14:34:  -> menuentry 'pxe (bhyve install)' {
Nov 24 16:14:34:  ->     root=cd0
Nov 24 16:14:34:  ->     linux16 /ipxe.krn
Nov 24 16:14:34:  -> }
Nov 24 16:14:34: /usr/local/sbin/grub-bhyve -c /dev/nmdm-pxe.1A -m /aux/vm/pxe/device.map -M 512M -r host -d /aux/vm/pxe pxe
Nov 24 16:14:37:  [bhyve options: -c 1 -m 512M -AHP -U 054fe809-f046-11e8-b345-bcee7bdf934c -u]
Nov 24 16:14:37:  [bhyve devices: -s 0,hostbridge -s 31,lpc -s 4:0,ahci-hd,/aux/vm/pxe/disk0.img -s 5:0,virtio-net,tap0,mac=58:9c:fc:05:52:fc]
Nov 24 16:14:37:  [bhyve console: -l com1,/dev/nmdm-pxe.1A]
Nov 24 16:14:37:  [bhyve iso device: -s 3:0,ahci-cd,/aux/vm/.iso/ipxe.iso]
Nov 24 16:14:37: starting bhyve (run 1)
Nov 24 16:14:37: bhyve exited with status 134
Nov 24 16:14:37: destroying network device tap0
Nov 24 16:14:37: stopped

Is there a way to get debug output?

tachnoraki commented 5 years ago

+1 for this feature, would be useful in enterprise environments.

churchers commented 5 years ago

@xaque208 You can add debug="yes" to the guest config file to get the bhyve output stored to bhyve.log. You could also try foreground mode. vm -f install guest iso

munixsoft commented 5 years ago

@xaque208 @churchers did you try to see how it is done in CBSD ? CBSD also use ipxe

gloumps commented 4 years ago

With the devel version of EDK II (port sysutils/uefi-edk2-bhyve-devel), you can used dhcp/http protocols to boot your VMs on the network. See my request https://github.com/churchers/vm-bhyve/pull/366