Adding ZVOL VIRTIO disks to a guest running on a host with the FreeBSD BHYVE hypervisor

On atlantis.domain (my FreeBSD BHYVE hypervisor host), I use these commands:

Install FreeBSD on a 10G disk.

vm create -s 10G guestname
 
vm install FreeBSD-12.1-RELEASE-amd64-memstick.img

vm console guestname


Add 8 30GB zvol-based disks

vm add -d disk -t zvol -s 30G guestname
vm add -d disk -t zvol -s 30G guestname
vm add -d disk -t zvol -s 30G guestname
vm add -d disk -t zvol -s 30G guestname
vm add -d disk -t zvol -s 30G guestname
vm add -d disk -t zvol -s 30G guestname
vm add -d disk -t zvol -s 30G guestname
vm add -d disk -t zvol -s 30G guestname

You will need to do

vm poweroff guestname
vm start guestname

because the guest does not seem to see the 8 30GB without power cycling. (rebooting won't work)

***

If you want the boot disk (the one create by "vm create") to be a zvol, you must edit the template:

root@atlantis:~ # zfs snapshot tank/vm-bhyve@2020-06-11-2145

root@atlantis:~ # mount -t zfs tank/vm-bhyve@2020-06-11-2145 /tank/vm-bhyve@2020-06-11-2145

root@atlantis:~ # vim /tank/vm-bhyve/.templates/default.conf


Did you know that "git diff" is a drop-in replacement for "diff -u". "git diff" is cool because it has colors.

root@atlantis:~ # git diff /tank/vm-bhyve@2020-06-11-2145/.templates/default.conf /tank/vm-bhyve/.templates/default.conf
diff --git a/tank/vm-bhyve@2020-06-11-2145/.templates/default.conf b/tank/vm-bhyve/.templates/default.conf
index a95af04..b8d0eee 100644
--- a/tank/vm-bhyve@2020-06-11-2145/.templates/default.conf
+++ b/tank/vm-bhyve/.templates/default.conf
@@ -5,3 +5,4 @@ network0_type="virtio-net"
 network0_switch="public"
 disk0_type="virtio-blk"
 disk0_name="disk0.img"
+disk0_dev="zvol"


Comments

Popular posts from this blog

Le tissu adipeux brun, la thermogénèse, et les bains froids

My 2022 Calisthenics split routine