# Building a port builder on the cloud - Root filesystem @ FreeBSD 13.0 on Azure?



## neogeo (May 10, 2022)

While researching an idea of using Microsoft Azure as a cloud service provider for a FreeBSD 13.1 build host - among other available options in cloud services and VPS instances, of course - I'd found the FreeBSD 13.0 release at the _Microsoft Azure Marketplace_.

The page at Microsoft's Azure Marketplace does not happen to mention the detail of whether it may be using a root-on-ZFS configuration, or a conventional UFS filesystem for the rootfs, or any other possible configuration. If it would be using ZFS on root, then of course that would serve to really simplify the process of updating to any 13.1-STABLE build - I might not even have to rebuild the base system and kernel on the cloud instance, if I could use the files from the /usr/src/release tooling e.g base.txz, kernel.txz and optionally lib32.txz, and any additional tooling for emulating the delete-old-* tgts, with an installation to a non-root boot environment under ZFS on FreeBSD 13 on the cloud machine

For the boot environment part in the upgrade, I've managed to work this out locally. After building the 13.1 sources from Git, I used the normal Makefile tooling to build the sources and create an ISO image, then installed it to bhyve on the same build machine. This was on a machine running a build of FreeBSD 12.3 built from STABLE-12 sources, a dedicated installation without any multi-boot filesystems. After building some bootstrap pkgs under the bhyve VM, then installing the new 13.1 build to a boot environment for the machine, lastly  updating the bootcode on the HDD for FreeBSD 13, it's booted successfully. I've now managed to transfer the poudriere filesystem from the builder environment in the bhyve VM back to the laptop's root zpool. It's booted to FreeBSD 13.1 now, presently in use for building the ports for what I'd like to install to other laptops, once upgrading everything to FreeBSD 13. It takes a considerable amount of time, however, to build all 1000+ ports in the full dependency graph, on a laptop.

For purpose of building a build infrastructure, maybe even a portable build infrastructure, perhaps it may be more cost effective to push the builds to the cloud somewhere, or to a VPS service, rather than trying to put together any new machine to use as a build host, or clunking through it with an old HP laptop from a clearance sale LoL. With 16 GB RAM in that laptop now, it runs pretty well for VM tests but is still pretty laggy for port updates. So I'm considering Azure, will take a look at Digital Ocean too. If the release images there might be using ZFS-on-root, I understand that that could really serve to simplify the post-installation tasks.

*Update*

In reviewing other options for cloud service hosting, Albert Valbuena has published a guide for adding a custom FreeBSD 13 image to a Digital Ocean cloud:  How to upload a FreeBSD custom image on DigitalOcean.

I haven't made any broad cost comparison, just looking at Digital Ocean now. For a long term, maybe I won't be going to Azure for this.

Albert noted a lack of IPv6 support for custom droplets at D.O, but there's some advice about ifconfig later in the document. There's a substantial introduction to cloud-init there.

An article by Justin Ellingwood introduces the matter of swap space at DO. Of course this can be adjusted for swap on a ZFS volume, whether beginning with a DO custom image for FreeBSD 13 with root on ZFS, or beginning with a DO official image for FreeBSD 12.2 with root on ZFS (e.g diskinfo vis a vis block size and overall volume size for the swap zvol, probably not a sparse zvol, late mount, probably with trimonce option) (can upgrade the zpool after the OS upgrade)

I'm interested in taking a look at FreeBSD on Azure. For a simple ports-build/ports-update host, maybe there could be anything in the management API that might serve to offset the big price difference and features difference compared to other cloud providers. D.O itself has root-on-ZFS (SSD storage at a certain volume, etc) available with FreeBSD 12.2 at this time.

Hopefully it may go well enough to simply update the cloud instance it to a 13.1 build. Though I'm not all sure if FreeBSD boot environments would be available in 12.2 -- I'd upgraded from FreeBSD 12.1 to 12.3-STABLE before beginning the migration to FreeBSD 13, had been interested in the news about ZFS in FreeBSD 13 and it's quite working out - can hopefully hack together something like a boot environment though, pursuant to updating to a FreeBSD 13 build (Update: Not needed, there's a bectl in FreeBSD 12.2 too)

I'm not sure if there's a ZFS-on-root option available with the Azure hosting for official FreeBSD images. Looking at FreeBSD 12.2 with root on ZFS on D.O there is a bectl(8) available there. I'd guess it will still need an update for gptzfsboot in the process of the upgrade to 13.1, will try that though. If the FreeBSD 13.1 release is scheduled for soon, probably as good a time as any to put a pkg builder together LoL.


----------



## brad (Oct 16, 2022)

The Foundation-provided images have UFS root. A while ago I was working on image building with Packer, but to build an image with the Azure chroot builder you'd need to add support for skipping mount/unmount (because ZFS does that differently than expected). My patch for that is well out of date and at some point I need to redo it for the current Packer codebase.

Poudriere can create a ZFS-root image; you'd just need to convert it to VHD (not VHDX) with qemu-img. And there's always the option of just running bsdinstall yourself. This script file should be a good start. I've got some code in progress to do something useful with the fancy Azure stuff but it's still WIP that I haven't had time for.

(I'm a Microsoft employee but none of the above is an official Microsoft product.)


----------

