churchers / vm-bhyve

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

bhyve guest crashing on initial boot for installation #505

Open michbsd opened 1 year ago

michbsd commented 1 year ago

FreeBSD 13.1-REL

ISOs

❯ vm iso
DATASTORE           FILENAME
default             alpine-extended-3.17.2-x86_64.iso
default             alpine-standard-3.17.2-x86_64.iso

Template:

❯ cat .templates/docker2.conf
loader="grub"
cpu=8
memory=8G
network0_type="virtio-net"
network0_switch="public"
disk0_type="virtio-blk"
disk0_name="disk0.img"
grub_install0="linux /boot/vmlinuz-lts initrd=/boot/initramfs-lts alpine_dev=cdrom:iso9660 modules=loop,squashfs,sd-mod,usb-storage,sr-mod"
grub_install1="initrd /boot/initramfs-lts"
grub_run0="linux /boot/vmlinuz-lts root=/dev/vda3 modules=ext4"
grub_run1="initrd /boot/initramfs-lts"

Running:

vm create -t docker2 -s 100G docker1
vm install docker1 alpine-extended-3.17.2-x86_64.iso

gives:

Starting docker1
  * found guest in /zroot/vm/docker1
  * booting...

However, the guest is crashing:

❯ cat vm-bhyve.log
Mar 10 12:07:04: generated static mac 58:9c:fc:0d:e9:2b (based on 'docker1:0:1678446424:0')
Mar 10 12:07:18: initialising
Mar 10 12:07:18:  [loader: grub]
Mar 10 12:07:18:  [cpu: 8]
Mar 10 12:07:18:  [memory: 8G]
Mar 10 12:07:18:  [hostbridge: standard]
Mar 10 12:07:18:  [com ports: com1]
Mar 10 12:07:18:  [uuid: b0d22ccb-bf33-11ed-87e7-d85ed343d476]
Mar 10 12:07:18:  [debug mode: no]
Mar 10 12:07:18:  [primary disk: disk0.img]
Mar 10 12:07:18:  [primary disk dev: file]
Mar 10 12:07:18: initialising network device tap0
Mar 10 12:07:18: adding tap0 -> vm-public (public addm)
Mar 10 12:07:19: bring up tap0 -> vm-public (public addm)
Mar 10 12:07:19: booting
Mar 10 12:07:19: create file /zroot/vm/docker1/device.map
Mar 10 12:07:19:  -> (cd0) /zroot/vm/.iso/alpine-extended-3.17.2-x86_64.iso
Mar 10 12:07:19:  -> (hd0) /zroot/vm/docker1/disk0.img
Mar 10 12:07:19: create file /zroot/vm/docker1/grub.cfg
Mar 10 12:07:19:  -> timeout=3
Mar 10 12:07:19:  -> menuentry 'docker1 (bhyve install)' {
Mar 10 12:07:19:  ->     root=cd0
Mar 10 12:07:19:  ->     linux /boot/vmlinuz-lts initrd=/boot/initramfs-lts alpine_dev=cdrom:iso9660 modules=loop,squashfs,sd-mod,usb-storage,sr-mod
Mar 10 12:07:19:  ->     initrd /boot/initramfs-lts
Mar 10 12:07:19:  -> }
Mar 10 12:07:19: /usr/local/sbin/grub-bhyve -c /dev/nmdm-docker1.1A -m /zroot/vm/docker1/device.map -M 8G -r host -d /zroot/vm/docker1 docker1
Mar 10 12:07:22:  [bhyve options: -c 8 -m 8G -AHP -U b0d22ccb-bf33-11ed-87e7-d85ed343d476 -u]
Mar 10 12:07:22:  [bhyve devices: -s 0,hostbridge -s 31,lpc -s 4:0,virtio-blk,/zroot/vm/docker1/disk0.img -s 5:0,virtio-net,tap0,mac=58:9c:fc:0d:e9:2b]
Mar 10 12:07:22:  [bhyve console: -l com1,/dev/nmdm-docker1.1A]
Mar 10 12:07:22:  [bhyve iso device: -s 3:0,ahci-cd,/zroot/vm/.iso/alpine-extended-3.17.2-x86_64.iso,ro]
Mar 10 12:07:22: starting bhyve (run 1)
Mar 10 12:07:22: bhyve exited with status 127
Mar 10 12:07:22: destroying network device tap0
Mar 10 12:07:22: stopped

If I attempt to restart the vm - it will boot up normally (without the bhyve install option) and obviously fail as the disk is not found - so I get stuck in bootloader.

Any ideas?

WanpengQian commented 1 year ago

The grub2-bhyve source is far behind grub2. I suggest using UEFI instead of grub to load Linux.