Skip to content
Goran Muminovic edited this page Apr 16, 2024 · 6 revisions

Using Cloud Images

You can use cloud images to create virtual machines. The vm img command will download the image to datastore and uncompress it if needed (.xz, .tar.gz, and .gz files are supported). The image should be in RAW or QCOW2 format. To use this feature you'll need install qemu or qemu-devel package:

pkg install qemu

To launch FreeBSD using official cloud image:

vm img https://download.freebsd.org/ftp/releases/VM-IMAGES/14.0-RELEASE/amd64/Latest/FreeBSD-14.0-RELEASE-amd64.raw.xz
vm create -t freebsd-zvol -i FreeBSD-14.0-RELEASE-amd64.raw freebsd-cloud
vm start freebsd-cloud

Using cloud-init

vm-bhyve has basic support for providing cloud-init configuration to the guest. You can enable it with -C option to vm create command. You can also pass public SSH key to be injected into the guest with option -k <file>. To use cloud-init install cdrkit-genisoimage package:

pkg install cdrkit-genisoimage

Example:

vm img https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64.img
vm create -t ubuntu-cloud -i xenial-server-cloudimg-amd64-uefi1.img -C -k ~/.ssh/id_rsa.pub cloud-init-ubuntu
vm start cloud-init-ubuntu
Starting cloud-init-ubuntu
* found guest in /zroot/vm/cloud-init-ubuntu
* booting...
ssh ubuntu@192.168.0.91
The authenticity of host '192.168.0.91 (192.168.0.91)' can't be established.
ECDSA key fingerprint is SHA256:6s9uReyhsIXRv0dVRcBCKMHtY0kDYRV7zbM7ot6u604.
No matching host key fingerprint found in DNS.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.0.91' (ECDSA) to the list of known hosts.
Welcome to Ubuntu 16.04.5 LTS (GNU/Linux 4.4.0-141-generic x86_64)

Ubuntu cloud sample conf file

# ➜  .templates cat ubuntu-cloud.conf
loader="uefi"
uefi_vars="yes"
cpu=4
memory=4096M
network0_type="virtio-net"
network0_switch="public"
graphics="yes"
xhci_mouse="yes"
graphics_res="1600x900"
zfs_zvol_opts="volblocksize=128k"
disk0_name="disk0"
disk0_dev="sparse-zvol"
disk0_type="virtio-blk"