I needed to do some testing with jails in FreeBSD and rather than enable nested jails I decided to use a FreeBSD VM. FreeBSD hosts VM images but their root disk is 30 GB when I only needed something in the 10 GB range. The official docs start with installing FreeBSD so I decided to replicate it with libvirt.

Overall it was straightforward except for getting the ISO to boot. The libvirt docs state to put the ISO first to boot from it. That did not work. The key part was discovering <boot dev='cdrom'/> in <os> to select the boot device.

After libvirt start freebsd-11 finished, running virsh console freebsd-11 brought up the boot sequence and then installer.

Working domain XML. The disk image was created using truncate.

<domain type='bhyve'>
    <name>freebsd-11</name>
    <uuid>82d9b876-d6bd-47a0-8c66-e2c8ddd967f2</uuid>
    <memory>262144</memory>
    <currentMemory>262144</currentMemory>
    <vcpu>1</vcpu>
    <os>
       <type>hvm</type>
       <boot dev='cdrom'/>
    </os>
    <features>
      <apic/>
      <acpi/>
    </features>
    <clock offset='utc'/>
    <on_poweroff>destroy</on_poweroff>
    <on_reboot>restart</on_reboot>
    <on_crash>destroy</on_crash>
    <devices>
      <disk type='file'>
        <driver name='file' type='raw'/>
        <source file='/vm/freebsd-11/freebsd-11.raw'/>
        <target dev='vda' bus='virtio'/>
      </disk>
      <disk type='file' device='cdrom'>
        <driver name='file' type='raw'/>
        <source file='/vm/freebsd-11/FreeBSD-11.2-RELEASE-amd64-bootonly.iso'/>
        <target dev='hda' bus='sata'/>
        <readonly/>
      </disk>
      <interface type='bridge'>
        <model type='virtio'/>
        <source bridge="bridge0"/>
      </interface>
      <serial type="nmdm">
        <source master="/dev/nmdm2A" slave="/dev/nmdm2B"/>
      </serial>
    </devices>
</domain>