Oracle Cloud has a fairly generous free tier, but one thing it does not include is the ability to use custom images, which require a paid account. This guide will show you how to install FreeBSD (or any custom image) using an alternative method.
Create two instances in Oracle Cloud using the default image. We will be using one for the FreeBSD server, and a temporary one for the installation process. Make sure to specify your SSH public key when creating the temporary instance.
On the FreeBSD instance page, stop it if it is running, and detach the boot volume.
On the temporary instance page, attach the FreeBSD instance’s boot volume as a block volume. Make sure to select Paravirtualized as the attachment type.
SSH into the temporary instance. Check the path of the newly attach volume. You can do this by running
lsblkand seeing which one has nothing mounted on it (it will most likely be
Then, run the following command to install a raw FreeBSD image onto the volume. Modify the release version and the volume path as needed.
curl https://download.freebsd.org/ftp/releases/VM-IMAGES/13.1-RELEASE/amd64/Latest/FreeBSD-13.1-RELEASE-amd64.raw.xz | xz -dc | sudo dd of=/dev/sdb bs=1M conv=fdatasync
Once the process is complete, detach the block volume from the temporary instance.
Re-attach the FreeBSD instance’s boot volume and start the instance.
Once the FreeBSD instance has booted, we can now configure it.
In the instance’s page, launch a Cloud Shell connection (you may need to press Enter in the console if it appears to be stuck for a while). This will give us preliminary access and allow us to enable SSH on the new server.
passwdto set a password for the
rootuser - make sure to choose a strong one.
Create a new user using
adduser. When asked to invite the user to other groups, enter
wheelto give the user root privileges.
Enable and start the SSH service by running
service sshd enable, followed by
service sshd start.
Copy your public key from your local machine using
Now you can SSH into your new FreeBSD server and do any additional setup. Enjoy!
To get IPv6 working on a FreeBSD instance on Oracle Cloud, we need support for
DHCPv6, which is not yet available in FreeBSD’s DHCP client
dhclient. To get
around this, we can use the
dual-dhclient-daemon package which supports
dual-stack DHCP. You can install and enable it with the following:
pkg install dual-dhclient-daemon sysrc dhclient_program=/usr/local/sbin/dual-dhclient
You will also need to enable IPv6 for your instance in the Oracle Cloud settings.