Skip to content

Commit

Permalink
ubuntu: add generate_config
Browse files Browse the repository at this point in the history
  • Loading branch information
msimerson committed Aug 26, 2024
1 parent 62f9445 commit fe14797
Showing 1 changed file with 57 additions and 5 deletions.
62 changes: 57 additions & 5 deletions provision/bhyve-ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

. mail-toaster.sh || exit

export BHYVE_VM_NAME=ubuntu-guest

create_bridge()
{
if ! grep -q "tap.up_on_open" /etc/sysctl.conf; then
Expand All @@ -13,16 +15,15 @@ create_bridge()
# create a named bridge for bhyve VMs
ifconfig bridge bridge-public 2>/dev/null || {
tell_status "creating bridge-public"
ifconfig bridge create name bridge-public
ifconfig bridge create name bridge-public up
get_public_facing_nic
ifconfig bridge-public addm "$PUBLIC_NIC"
ifconfig bridge-public up
}

# create tap interface for VM
ifconfig tap-ubuntu 2>/dev/null || {
tell_status "creating VM tap interface"
ifconfig tap create name tap-ubuntu
ifconfig tap create name tap-ubuntu up
ifconfig bridge-public addm tap-ubuntu
}

Expand Down Expand Up @@ -72,11 +73,61 @@ install_ubuntu_bhyve_zfs()
zfs set recordsize=64K "$ZFS_BHYVE_VOL/bhyve"
fi

if ! zfs_filesystem_exists "$ZFS_BHYVE_VOL/bhyve/ubuntu-guest"; then
zfs create -V20G -o volmode=dev "$ZFS_BHYVE_VOL/bhyve/ubuntu-guest"
if ! zfs_filesystem_exists "$ZFS_BHYVE_VOL/bhyve/$BHYVE_VM_NAME"; then
zfs create -V20G -o volmode=dev "$ZFS_BHYVE_VOL/bhyve/$BHYVE_VM_NAME"
fi
}

generate_config()
{
tee "$ZFS_BHYVE_VOL/bhyve/$BHYVE_VM_NAME.conf <<EO_BHYVE_CONF
name=$BHYVE_VM_NAME
cpus=1
#cores=1
#threads=1
#sockets=1
memory.size=1G
memory.wired=false
acpi_tables=true
destroy_on_poweroff=true
#uuid=""
pci.0.0.0.device=hostbridge
#pci.0.2.0.device=e1000 (use for Windows)
pci.0.2.0.device=virtio-net
pci.0.2.0.type=tap
pci.0.2.0.backend=tap-ubuntu
pci.0.3.0.device=virtio-blk
pci.0.3.0.path=/dev/zvol/$ZFS_BHYVE_VOL/bhyve/$BHYVE_VM_NAME
pci.0.4.0.device=ahci
pci.0.4.0.path=/$ZFS_BHYVE_VOL/ISO/ubuntu-22.04.2-live-server-amd64.iso
pci.0.29.0.device=fbuf
pci.0.29.0.wait=false
pci.0.29.0.rfb=0.0.0.0:5900
pci.0.29.0.w=800
pci.0.29.0.h=600
pci.0.30.0.device=xhci
pci.0.30.0.slot.1.device=tablet
pci.0.31.0.device=lpc
lpc.com1.device=stdio
#lpc.com1.device=/dev/nmdm0A
#lpc.com2.device=/dev/nmdm1A
lpc.bootrom=/usr/local/share/uefi-firmware/BHYVE_UEFI.fd
EO_BHYVE_CONF
}
install_ubuntu_bhyve()
{
if ! grep -q vmm_load /boot/loader.conf; then
Expand All @@ -92,6 +143,7 @@ install_ubuntu_bhyve()
stage_pkg_install bhyve-firmware grub2-bhyve || exit
#configure_grub
tell_status "launching bhyve VM with CD installer"
bhyve \
-H -P -w \
-c 1 -m 1G \
Expand Down

0 comments on commit fe14797

Please sign in to comment.