Discussion:
Building ZFS-based VM images
Alan Somers
2021-05-06 15:17:30 UTC
Permalink
It's easy to build a UFS-based VM image just by setting WITH_VMIMAGES in
release.conf and running release.sh. But what about ZFS-based images?
What's the easiest way to build a ZFS-based VM image, using a pool layout
similar to what the interactive installer uses?
-Alan
tech-lists
2021-05-06 18:09:15 UTC
Permalink
Post by Alan Somers
It's easy to build a UFS-based VM image just by setting WITH_VMIMAGES in
release.conf and running release.sh. But what about ZFS-based images?
What's the easiest way to build a ZFS-based VM image, using a pool layout
similar to what the interactive installer uses?
-Alan
Hi,

I don't know of a way with make release

Briefly, the way I do zfs on amd64 vm is (given you're already set up on bhyve):

a: truncate -s 64G filename.img
b: sh vmrun.sh -c 4 -m 32768M -t tap1 -d filename.img -i -I
freebsd-installer.iso vmname
c: run through the installer, selecting auto-zfs on the way.
d: stop the reboot, run the vmrun.sh again and omit the -i -I
freebsd-installer.iso bit

(in my context, vmrun.sh is a symlink to
/usr/share/examples/bhyve/vmrun.sh in the dir i'm working in)

[section 22.7 FreeBSD as a Host with bhyve]
--
J.
David Chisnall
2021-05-07 13:37:55 UTC
Permalink
Post by Alan Somers
It's easy to build a UFS-based VM image just by setting WITH_VMIMAGES in
release.conf and running release.sh. But what about ZFS-based images?
What's the easiest way to build a ZFS-based VM image, using a pool layout
similar to what the interactive installer uses?
The only way that I've deployed FreeBSD VMs in Azure has been to run the
installer in Hyper-V locally and then upload it as a template.

You need to be *really* careful with this mode though, because ZFS gets
really confused if two pools or two VDEVs have the same UUIDs. This
means that you can't just attach one VM's disk to another for recovery
(I also have a UFS image that I use for recovery). It would be great if
it were possible to set a flag somewhere telling the storage subsystem
to regenerate the UUIDs of everything (including GPT partitions) on
first boot.

David
Allan Jude
2021-05-07 16:47:51 UTC
Permalink
Post by Alan Somers
It's easy to build a UFS-based VM image just by setting WITH_VMIMAGES in
release.conf and running release.sh. But what about ZFS-based images?
What's the easiest way to build a ZFS-based VM image, using a pool layout
similar to what the interactive installer uses?
-Alan
_______________________________________________
https://lists.freebsd.org/mailman/listinfo/freebsd-current
With the new scripting support, it is fairly easy with poudriere-image

It also has the advantage of being able to build the images from
poudriere jails you already have (or can build from FTP without compiling).

The pre/post build script stuff is merged already, although my example
scripts are in a different pull request that I need to rebase around
some restructuring first.

Anyway, you can use poudriere-image with the pre/post scripts included here:

https://github.com/freebsd/poudriere/pull/731/files#diff-6607907a033a4e5e5e21da56960ed7ccbfb6dd4a85d66615553d2221d75c0998

and it will make a VM image with the same layout as if you had used the
installer (or you can customize it as you see fit)

I'm currently using this to build images for AWS and bhyve, but also to
generate installer ISOs that run a script to format the drives and
create the zpool, then 'fetch -o - url | zfs recv -F zroot' to install a
replication stream of an entire pool.

For upgrades, we do the same but only replace the boot environment.
--
Allan Jude
Loading...