Hi there my fart-clouder, I have been working for a few days in a little program to create OpenBSD vms over Proxmox which runs QEMU inside. We have QEMU on OpenBSD by ports. The idea is to create a small VM with QEMU and make it our template to later clone it on Proxmox and create X more.
We need to install QEMU on our OpenBSD if you want to do this already with Proxmox you can do so too, but I will focus on the OpenBSD as always try to do:
$ doas pkg_add qemu
That was hard rock! Do I need to tell you again to RTFM? Yes, I need to. The 'READMEs' are in only one place /usr/local/share/doc/pkg-readmes and what you are looking for is "qemu", go and read it because I will use it to write this short article and also will help you to understand how to adapt the configuration to another needs on your setup that I will not talk about :).
For my needs I prefer to use a small disk and then add another extra and mount it somewhere on the system where is need it, the setup will be a 10GB disk with the default layout on the installation, I will not guide you over it, you probably know how to do it, if you ever installed Ubuntu... well, this is easier and faster.
Let's download the cd73.iso, create the qcow2 disk and start the vm, the rest it's on you, install your system and make it nice as you like, it will be the base for the rest of the vms you will clone from it.
$ mkdir VMs
$ cd VMs
$ ftp -V https://cdn.openbsd.org/pub/OpenBSD/snapshots/amd64/cd73.iso
$ qemu-img create -f qcow2 openbsd-current.img 10G
$ ls -al
total 21672
drwxr-xr-x 2 gonzalo gonzalo 512B May 16 20:26 ./
drwxr-xr-x 31 gonzalo gonzalo 1.5K May 16 20:26 ../
-rw-r--r-- 1 gonzalo gonzalo 10.3M May 16 19:03 cd73.iso
-rw-r--r-- 1 gonzalo gonzalo 192K May 16 20:26 openbsd-current.img
From the README:
NOTE: start this inside an xterm or equivalent.
NOTE: be sure to choose serial console during install.
NOTE: -no-fd-bootchk permits booting faster when no floppy is
in use, but is not supported for qemu-system-sparc.
$ qemu-system-x86_64 -m 64 -monitor stdio -no-fd-bootchk \
-hda openbsd-current.img -cdrom cd73.iso -boot d
Or if you want a serial console:
$ qemu-system-x86_64 -m 64 -no-fd-bootchk -hda openbsd-current.img \
-cdrom cd73.iso -boot d -nographic -serial telnet::2222,server
$ telnet 127.0.0.1 2222
SeaBIOS (version rel-1.16.2-0-gea1b7a073390-prebuilt.qemu.org)
iPXE (http://ipxe.org) 00:03.0 CA00 PCI2.10 PnP PMM+02FD11A0+02F311A0 CA00
Booting from DVD/CD...
CD-ROM: E0
Loading /7.3/AMD64/CDBOOT
probing: pc0 com0 mem[639K 62M a20=on]
disk: fd0 hd0+* cd0
>> OpenBSD/amd64 CDBOOT 3.56
At this point you will have a little screen or serial console to install OpenBSD on those 10GB, after you finish it, just turn off the VM, and we'll scped the disk to Proxmox and create the template from it.
$ scp openbsd-current.img gonzalo@proxmox:/home/gonzalo/templates
... SCP MAGIC ...
$ ssh gonzalo@proxmox
... SSH MAGIC ...
proxmox$ cd templates
proxmox$ sudo qm create 900 --name openbsd-current-template --memory 512 --net0 virtio,bridge=vmbr0
proxmox$ sudo qm importdisk 900 openbsd-current.img local-lvm
proxmox$ sudo qm set 900 --scsihw virtio-scsi-pci --scsi0 local-lvm:vm-900-disk-0
proxmox$ sudo qm set 900 --ide2 local-lvm:cloudinit
proxmox$ sudo qm set 900 --boot c --bootdisk scsi0
proxmox$ sudo qm set 900 --serial0 socket --vga serial0
proxmox$ sudo qm set 900 --ipconfig0 ip=dhcp
proxmox$ sudo qm resize 900 scsi0 10G
proxmox$ sudo qm template 900
To breakdown a bit the previous commands, qm is the QEMU/KVM Virtual Machine Manager of Proxmox so basically you can manage all your vms from it. We created a vm with the id 900 (I like to make it high so it won't mix with real/normal vms), we set "openbsd-current-template" as name, with 512mb of ram and a virtio network interface over vmbr, we import the openbsd-current.img disk on our storage, we set a bunch of other parameters that are needed for cloud-init such as ide2, virtio-scsi-pci, serial and the type of networking (dig into those yourself to adapt it to your needs, I kept it pretty default, but it could change on your setup). We finally create the template with our id and you should see it on your web dashboard.
From now on you can full clone of the template and create many other vms, on the next article, fart-init to clean up and set up these vms and Terraform to make all this with a couple of commands. Cheers!