
Installing FreeBSD on OVHcloud Bare Metal Server
OVHcloud supports FreeBSD on some, but not all of their server offerings. In this article I'll demonstrate how to install FreeBSD on any OVHcloud bare metal server instance.
At Conrad Research, we deploy on FreeBSD to leverage its jails subsystem for easily implementing immutable infrastructure. One of our preferred providers is OVHcloud's bare metal servers. They don't support FreeBSD out of the box so here is the step-by-step guide on how to install it.
Steps
1. Prep the install image.
NOTE: As of the writing of this article the latest version is FreeBSD 14.3
Download the FreeBSD image in qcow2 format with the ZFS filesystem and amd64 architecture (don't use the image with CloudInit).
curl -O https://download.freebsd.org/releases/VM-IMAGES/14.3-RELEASE/amd64/Latest/FreeBSD-14.3-RELEASE-amd64-zfs.qcow2.xz
Then unpack it:
On macOS, install 'xz' if not already available:
brew install xz
unxz FreeBSD-14.3-RELEASE-amd64-zfs.qcow2.xz
Compute it's SHA256 checksum hash. You'll need this value in step 4.
sha256sum FreeBSD-14.3-RELEASE-amd64-zfs.qcow2
Upload the image to a publically accessible location, such as an S3 bucket or a web server. You'll need this URL in step 4.
Top tip: use a presigned URL to give access to the install process without making the image public.
2. Start the installation.
Log into your OVHcloud account and navigate to your dedicated server instance. Under 'Operating System', select the three dots menu and choose 'Install my server'. This will bring up a dialog box where you configure the installation. Proceed to step 3 below.
3. 'Install my server' step 1.
- For 'Type of OS', select 'Custom'.
- Expand the 'Custom' section and select 'Bring your own image'.
- The form will then skip to 'Install my server' step 4. See next step below.
4. 'Install my server', step 4.
- For 'Image URL', input the URL of the uploaded image from step 1.
- For 'Image Type', select 'qcow2'.
- For 'Image Checksum', input the checksum value you calculated in step 1.
- For 'Checksum Type', select 'SHA256'.
- For 'Path of the EFI bootloader from the OS installed on the server', input '/boot/loader.efi'.
All other settings are optional. You're now ready to proceed with the installation. FreeBSD will boot automatically after installation.
5. Configure server through KVM.
Go to the server instance's dashboard and click 'IPMI/KVM' > Serial Over LAN. > SSH SOL > Add SSH Key.
It will think for awhile and then give you a ssh username and login url. Connect to that url using ssh and the ssh key you provided.
ssh -i ~/.ssh/NAME_OF_YOUR_SSH_KEY] ipmi@CONNECTION_URL
Once logged in, do some basic configuration.
Create a password for root.
passwd root
Create 'freebsd' user, add to wheel group, and set the user's password.
pw useradd freebsd -m -G wheel -s /bin/sh
passwd freebsd
Add your SSH public key to the 'freebsd' user's authorized_keys file.
# Switch to 'freebsd' user
su freebsd
# Create .ssh directory for freebsd user
mkdir -p ~/.ssh
# Add your SSH public key
echo "[YOUR SSH PUBLIC KEY]" >> ~/.ssh/authorized_keys
# Exit the freebsd user session to return to root.
exit
Configure SSH daemon.
# Disable password based authentication. IE. require public key authentication.
sed -i '' 's/^#*PasswordAuthentication.*/PasswordAuthentication no/' /etc/ssh/sshd_config
sed -i '' 's/^#*UsePAM.*/UsePAM no/' /etc/ssh/sshd_config
# Disable root login.
sed -i '' 's/^#*PermitRootLogin.*/PermitRootLogin no/' /etc/ssh/sshd_config
# Disable empty passwords.
sed -i '' 's/^#*PermitEmptyPasswords.*/PermitEmptyPasswords no/' /etc/ssh/sshd_config
# Enable SSH
sysrc sshd_enable="YES"
# Start SSH service
service sshd start
Then expand the ZFS pool to the maximum available partition size. To find the correct device for your zpool run the below command. This will show you the device name (e.g., /dev/ada0p2, /dev/da0p2, /dev/nvd0p2)
zpool status zroot
Then expand the ZFS pool using the device name from above.
zpool online -e zroot /dev/nda0p4
Open up a new terminal and verify that you can ssh into your server.
ssh -i ~/.ssh/NAME_OF_YOUR_LOCAL_SSH_KEY freebsd@YOUR_SERVER_IP
6. Conclusion
You're now ready to enjoy your FreeBSD server! Cheers 🥂
If you want to configure Cloudflare Tunnels see our previous posts:
- Secure FreeBSD by Allowing Access Only Through Cloudflare Tunnels
- Cloudflare Tunnels on FreeBSD 14.3
BONUS: Friendly reminder to always run the following after a fresh install from a memory stick to make sure your system has the latest patches.
freebsd-update fetch && freebsd-update install