Deploying FreeBSD on Oracle Cloud
Deploying FreeBSD on Oracle Cloud
Why Leverage FreeBSD for Oracle Cloud’s new Arm Instances
FreeBSD is the OS of choice for leveraging the most out of your Oracle Cloud deployment. Take advantage of the raw processing power the Ampere Altra has to offer and take the next step in evolving your infrastructure.
FreeBSD in Oracle Cloud
Although most people associate ARM processors with small personal devices, ARM64 servers have grown by leaps and bounds in the last few years. For example, Ampere Altra machines are available in 80 and 160 core variants and can support up 512GB of RAM. These machines are core to Oracle Clouds ARM server offering.
Oracle Cloud makes these hugely powerful Ampere servers available on demand as virtual machine hosts and as dedicated bare metal instances. FreeBSD is an excellent choice in this environment, since the ARM64 architecture was promoted to the Tier 1 support category as of FreeBSD 13.0-RELEASE. This Tier 1 support reflects the FreeBSD project’s commitment to offering timely releases, support, and packages for the platform.
Oracle Cloud’s free tier includes the following resources, which can be dedicated to a single large virtual machine, or allocated to up to four smaller virtual machines:
- 4 Arm-based Ampere A1 cores
- 24 GiB of RAM
- 2 Block Volumes Storage, 200 GiB total
- 10 GiB Object Storage – Standard
- 10 GiB Object Storage – Infrequent Access
- 10 GiB Archive Storage
The Always Free Tier offers enough space to experiment with using FreeBSD ARM64 virtual machines for a wide range of different projects.
In this article we will explore running FreeBSD 13.1 on Oracle Cloud A1 virtual machine instances.
Building a FreeBSD 13.1 Image
Official ARM64 FreeBSD 13.1-RELEASE images are not yet directly available in Oracle Cloud, but FreeBSD’s build infrastructure already makes it easy to build high quality custom images and experiment with them in Oracle Cloud.
FreeBSD’s easy-to-use build infrastructure is very solid and offers you access to the same tools used to make the official FreeBSD releases—and with a couple of commands, we can create our own custom images.
For this article we will make a basic default image, but it is entirely possible to do any configuration that you want on the image before using it as a template for virtual machines.
To build our custom image we need to follow these steps:
- Clone the FreeBSD source tree
- patch in support for Oracle Cloud images
- make buildworld and make buildkernel
- make a release
Once we have completed these steps we can upload the image to Oracle Cloud and use the image to create an instance.
For the build here we need to use a FreeBSD host machine, FreeBSD can be cross built from other operating systems, but that process is outside the scope of this article.
We need to apply a patch from the review at D34746, this patch adds a new cloud image target (OCI) and includes the tools required for an image to work in Oracle Cloud.
To build the image with the required patch we need to grab the FreeBSD source with git and apply the patch. We do this with the following 4 commands:
$ git clone https://git.freebsd.org/src.git src $ fetch https://reviews.freebsd.org/file/data/42ys7pmkhmjdsft5ul6m/PHID-FILE-ppags7fnq6auz36q4i3e/D34746.diff $ cd src $ git apply -p0 ../D34746.diff
With the tree patched we can build world and kernel. My build system is running amd64, so I need to specify the TARGET as arm64 and the TARGET_ARCH as aarch64. Doing so on an arm64 system won’t hurt.
$ make -j `sysctl -n hw.ncpu` buildworld buildkernel TARGET=arm64 TARGET_ARCH=aarch64 KERNCONF=GENERIC $ cd release # make -DNOPORTS -DNOSRC KERNCONF=GENERIC WITH_CLOUDWARE=yes CLOUDWARE=OCI cloudware-release
The build step takes about 30 minutes on a Ryzen 7 3800X system. Once the build and release phases have completed you will have a qcow2 image in /usr/obj/arm64.aarch64/release/ called oci.qcow2.
Uploading the Custom Image
Next, we need to perform a couple of steps to upload the image we have created to Oracle Cloud’s object storage and turn it into a functional virtual machine image.
All of these steps can be accomplished using the Oracle command line tools, but here we will use the console (web interface).
First, we need to visit the object storage page and create a bucket. From the menu at the top left, navigate Through ‘Storage’->‘Object Storage and Archive Storage’->‘Buckets’ as shown below:
From that page create a standard storage bucket called ‘freebsd-images’:
Inside that bucket upload the OCI image and give it a name like ‘FreeBSD-13.1’:
Once the upload has completed, we can use the image to create an instance template:
From the menu at the top left navigate ‘Compute’->‘Custom Images’ and then click `Import Image`:
Now, select the Object from the freebsd-images bucket you created. The format needs to be set to QCOW2 and the Launch mode needs to be set to ‘Emulated mode’.
Finally,we need to modify the image shape a little bit to make the image functional. We need to add the shape ‘VM.Standard.A1.Flex’ to the list of shapes for the image, then modify the image capabilities (in the ‘Edit Image Capabilities’ menu):
For our image to boot we need to disable BIOS boot mode and SR-IOV networking, since ARM-based shapes do not support SR-IOV:
With these tweaks, we’re ready to use the image to create instances.
Launching Instances on Oracle Cloud
Now that we have the image created and uploaded, we can use it to provision new virtual machine instances.
From the Top Left menu select ‘Compute’->‘Instances’ and then ‘Create Instance’.
In the Create Instance dialog, click ‘edit’ on ‘Image and Shape’, ‘Change Image’ and then from the drop down change it from ‘Platform Images’ to ‘Custom Images’:
From that template select the image we uploaded:
Under ssh keys, you should upload or paste the public part of your own ssh key. If you need help on creating a key the Klara EC2 article has instructions.
Once you click create, it will take about 5 minutes for the new instance to be provisioned and created. Once that process finishes, you will be able to ssh to the virtual machine or connect via the serial console.
The ssh keys you provided earlier are passed to the virtual machine via cloud-init, and the default user for these FreeBSD Virtual Machines is freebsd:
$ ssh firstname.lastname@example.org freebsd@instance-20220515-0936:~ % uname -a FreeBSD instance-20220515-0936 13.1-RELEASE FreeBSD 13.1-RELEASE 13.1-oci-n250149-261a859e39d3 GENERIC arm64
Oracle Cloud has great console connection support, and this applies to FreeBSD virtual machines there too. You can create a console connection by clicking ‘Console connection’ at the bottom left of the instance page and then clicking ‘Launch Cloud Shell’.
By default, there is no password on the root account and you can press enter to get a shell:
Although this article focused on the use of FreeBSD ARM64 virtual machines, Oracle Cloud also offers bare metal tiers on these high performance Ampere machines, with full access to an entire 80 or 160 core system.
Soon, official project images for ARM64 FreeBSD will be available directly in Oracle Cloud, making experimentation even easier and the full use of bare metal instances possible.