Skip to content

Instantly share code, notes, and snippets.

@cneira
Forked from mgerdts/README.md
Created July 21, 2022 22:37
Show Gist options
  • Save cneira/bf7e29dbf4a5a44afa7dc2ab4e872743 to your computer and use it in GitHub Desktop.
Save cneira/bf7e29dbf4a5a44afa7dc2ab4e872743 to your computer and use it in GitHub Desktop.
Install windows with bhyve

These are bare-bones instructions for creating a Windows image for bhyve on SmartOS. You will need a platform image that has the fix for OS-7117. Platform images that I've used in testing are here: iso tgz usb

Create a volume that will be the disk.

zfs create -o volblocksize=4k -V 16g -s zones/hdd-windows

This script will be used for booting from the CD.

#!/bin/sh

bootrom=/usr/share/bhyve/uefi-rom.bin

[ "$1" = "-k" ] || pfexec bhyvectl --vm=windows --destroy
bhyve -H -w \
        -s 0,hostbridge \
        -B "1,product=SmartOS HVM" \
        -s 31,lpc \
        -l bootrom,$bootrom \
        -l com1,stdio \
        -c 2 \
        -m 2G \
        -s 3:0,ahci-cd,/zones/media/win2016eval.iso \
        -s 4:0,ahci-hd,/dev/zvol/rdsk/zones/hdd-windows \
        -s 28,fbuf,vga=off,tcp=0.0.0.0:5900,w=1024,h=768,wait -s 29,xhci,tablet \
        windows

You will need to connect via vnc and hit the any key to tell it to boot from the CD. After doing the first chunk of work, Windows willl reboot. You will need to re-run the script one or more times to complete the installation. In the subsequent boots, you do not want to boot from the CD, so don't hit the any key. Note that the ,wait on the fbuf argument will cause bhyve to wait for the VNC connection before booting.

Once the installation is complete, we need to associate zones/hdd-windows with a VM. The simplest way to do that is with the following.

First, stop the windows VM. Shutdown from within the VM or kill the bhyve process (-TERM for an orderly shutdown, -KILL or -9 for pull the cord).

Next, create an empty vm and swap disks.

vmadm create -f bhyve-empty.json
uuid=...
zfs destroy zones/$uuid/disk0
zfs rename zones/hdd-windows zones/$uuid/disk0

Now you should be able to start the Windows VM with vmadm start $uuid

Limitiations

Some things are not fully baked. We're working on them.

  • Currently you must configure networking statically or have an external DHCP server.
  • The procedure above does not include virtio drivers for disks or networking. It is unknown whether any other networking emulation works with bhyve on SmartOS. The virtio drivers we use on kvm and will likely use with bhyve are on this iso. It should be possible to add that iso to the command line during installation and adjust hdd-windows to use virtio-blk instead of ahci.
{
"brand": "bhyve",
"alias": "bhyve-uefi",
"vcpus": 2,
"autoboot": false,
"ram": 2048,
"disks": [
{
"boot": true,
"model": "ahci",
"size": 10240
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment