At work, building Linux VMs is a fully automated process, done with a single command.

FreeBSD VMs on the other hand, were never automated, as we install them very rarely.

As it happens rarely, the few times I needed to install a FreeBSD VM, I would scramble around to find how to mount an ISO on the VM (maybe I should have documented it the first time I needed?).

Anyway, now it’s properly documented, here.

Edit your domain definition:

1
$ virsh edit <domain_name>

Then somewhere in the <devices> section, add the following:

1
2
3
4
5
6
7
<disk type='file' device='cdrom'>
  <driver name='qemu' type='raw'/>
  <source file='/tmp/whatever.iso'/>
  <target dev='hdc' bus='ide'/>
  <readonly/>
  <address type='drive' controller='0' bus='1' unit='0'/>
</disk>

Last step, in the <os> section, add, before the hd one:

1
<boot dev='cdrom'/>

Done, start the VM and it should boot straight into the ISO.