Skip to content

Instantly share code, notes, and snippets.

@c0m4r
Last active June 16, 2025 07:13
Show Gist options
  • Save c0m4r/0401f6b53d35b0c34a4f51eef68af377 to your computer and use it in GitHub Desktop.
Save c0m4r/0401f6b53d35b0c34a4f51eef68af377 to your computer and use it in GitHub Desktop.
FreeBSD installation on OVH VPS

FreeBSD installation on OVH VPS

This guide explains how to install the FreeBSD on OVH VPS. This might also work for other VPS providers with the proper rescue system in place.

Inspired by https://www.klajnszmit.net/unix-bsd-linux/openbsd-on-ovh-vps

Table of contents:

1. Rescue mode

Log into OVHcloud, switch to your VPS control panel, select Boot -> Restart into Rescue Mode. It takes up to 3 minutes to boot into rescue mode. You can read the rescue root account password from KVM (Console) or from the link sent via email.

Let's copy our SSH Key into the rescue environment first for convenience and log in:

if [ ! -e ~/.ssh/id_ed25519 ] ; then ssh-keygen -t ed25519 ; fi
ssh-copy-id [email protected]
ssh [email protected]

2. Disk preparation

Check available drives:

fdisk -l

[RESCUE] root@vps-XXXXXXXX:~ $ fdisk -l
Disk /dev/sda: 2.93 GiB, 3145728000 bytes, 6144000 sectors
Disk model: QEMU HARDDISK
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x9fdc479e

Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 6141951 6139904 2.9G 83 Linux

Disk /dev/sdb: 40 GiB, 42949672960 bytes, 83886080 sectors
Disk model: QEMU HARDDISK
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xbb326e04

Device Boot Start End Sectors Size Id Type
/dev/sdb1 * 2048 83886079 83884032 40G 83 Linux

We are interested in /dev/sdb, which is our VPS's drive. We need to wipe what's left on that drive and exit back to our local machine:

wipefs -a /dev/sdb
exit

3. Download and deploy FreeBSD

We will use the FreeBSD VM image which includes everything we need.

Head over to freebsd.org/where and choose VM -> amd64 of the latest release.

At the time of writing this it was 14.0.

Download *-amd64.raw.xz

wget https://download.freebsd.org/releases/VM-IMAGES/14.0-RELEASE/amd64/Latest/FreeBSD-14.0-RELEASE-amd64.raw.xz

And then transfer it over ssh:

cat FreeBSD-14.0-RELEASE-amd64.raw.xz | ssh [email protected] "xz -dc | dd of=/dev/sdb bs=1M"

Now make sure that everything went as expected:

ssh [email protected]
fdisk -l /dev/sdb

You should see something like this:

Disk /dev/sdb: 40 GiB, 42949672960 bytes, 83886080 sectors
Disk model: QEMU HARDDISK
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 085DD663-7FB6-11EE-A7BA-002590EC5BF2

Device Start End Sectors Size Type
/dev/sdb1 34 155 122 61K FreeBSD boot
/dev/sdb2 156 66739 66584 32.5M EFI System
/dev/sdb3 66740 2163891 2097152 1G FreeBSD swap
/dev/sdb4 2163892 12649651 10485760 5G FreeBSD UFS

Don't worry about the /dev/sdb4 size, it will extend itself after first boot.

Now restart your VPS via the OVH control panel ($ reboot won't work).

FreeBSD should now boot and you can continue your setup via KVM (Console) with FreeBSD Handbook.

image

4. Post-installation

  • Change root password: passwd
  • Update the system: pkg update
  • Install useful stuff: pkg install bash bash-completion bind-tools curl gnu-watch htop lsblk lsof mc mtr-nox11 nano vim wget whois
  • Enable the SSH Server
  • Take care of Security

If you found this article helpful, please consider making donation to a charity on my behalf. Thank you.

Enjoy your FreeBSD adventure!

image

@pcataddc
Copy link

Succes install with your tutorial, booting got stuck on "boot/entropy size = 0x1000"
https://i.gyazo.com/90e1041313ee2ed74c6b570e53ea2183.png

@Malkaviel
Copy link

Malkaviel commented Mar 30, 2024

Thank you very much for this short tutorial, it worked like a charm!
However, after the successful installation, I had to troubleshoot some issues.
I will let some information below for the people who will use this guide in the future.

Before starting, collect those information:
- hostname
it should look like "vps-********.vps.ovh.net"
- static IPv4 and IPv6 addresses, and the IPv6 gateway
Found on OVH dashboard (OVH Bare Metal Cloud -> VPS dashboard)
- OVH DNS IPv4 address
it should resolve to "cdns.ovh.net." (I found it in a YAML file in /etc/netplan/ on Ubuntu 23.xx before starting the rescue mode)

VPS used

  • Name: vps2020-starter-1-2-20
  • CPU: 1 vCore
  • RAM: 2 GB
  • Storage: 20 GB.

FreeBSD VM image used

  • name: FreeBSD-14.0-RELEASE-amd64.raw.xz
    Don't forget to update your xz package, 5.6.0 and 5.6.1 are compromised!
  • version: 14.0-RELEASE
  • Arch: AMD64
  • Filesystem: UFS

Disk partitions
The disk partition was 1 GB of swap, the rest for /usr. I expected 2-4 GB of swap and different partitions for /var, /tmp and /usr.
I guess one would need to create its own VM image, with QEMU or something like that.

Keyboard layout
By default, the keyboard is QWERTY.
To find the keyboard layout you want, type kbdmap.
You will be able to select your layout, and its name will be displayed in the console.
The layout will NOT change however.
You need to add the following line to your /etc/rc.conf file: keymap="<your layout name>".
example: keymap="ch-fr.kbd"

Network configuration initially correct, but rc.conf incorrect
After logging with OVH's KVM, the system was working fine:

  • ifconfig reported the correct IPv4 address
  • /etc/resolv.conf was correct:
search openstacklocal
nameserver <OVH DNS IPv4 address>

However, /etc/rc.conf was FULL of crap:

  • missing config for IPv4 (ifconfig_vtnet0)
  • Incorrect (I think?) config for IPv6 (ifconfig_vtnet0_ipv6)
  • duplicated config about ZFS, even though the image uses UFS.
  • Wrong hostname

IF YOU RUN service netif restart && service routing restart, YOUR NETWORK AND DNS CONFIG WILL BE MESSED UP.

Following the Network chapter of the FreeBSD handbook was enough to fix that.

My final rc.conf looked like this:

hostname="<your hostname>"
keymap="ch-fr.kbd"

ifconfig_vtnet0="inet <VPS IPv4 IP> netmask 255.255.255.0"
defaultrouter="<VPS IPv4 IP with last number replaced by 1>"
ifconfig_vtnet0_ipv6="inet6 <VPS IPv6 IP> prefixlen 64"
ipv6_defaultrouter="<VPS IPv6 Gateway>"

sshd_enable="YES"
ntpd_enable="YES"
moused_nondefault_enable="NO"
dumpdev="AUTO"

And /etc/resolv.conf like this:

search openstacklocal
nameserver <OVH DNS IPv4>

Run service netif restart && service routing restart, check that both files are still correct and check that ping -c2 www.FreeBSD.org is working too.

Now you can continue with the Security chapter of the FreeBSD handbook.

@patr1xcore
Copy link

patr1xcore commented Apr 8, 2024

Hi.

I have an issue with this.

After running this
wget https://download.freebsd.org/releases/VM-IMAGES/14.0-RELEASE/amd64/Latest/FreeBSD-14.0-RELEASE-amd64.raw.xz
It stops at 66% and I get this error:
Cannot write to ‘FreeBSD-14.0-RELEASE-amd64.raw.xz’ (No space left on device).

I didn't find any solution unfortunately, so perhaps anyone will be able to help here please?

EDIT:
I solved the above issue, although I am not sure if it's really a solution.
wget https://download.freebsd.org/releases/VM-IMAGES/14.0-RELEASE/amd64/Latest/FreeBSD-14.0-RELEASE-amd64.raw.xz -O /dev/sdb

NEW ISSUE:
FreeBSD doesn't boot and when I run fdisk -l /dev/sdb, it doesn't show what it is supposed to show.

I am not sure what am I doing wrong so I would really appreciate if someone could help...

Thanks a lot.

@c0m4r
Copy link
Author

c0m4r commented Apr 9, 2024

@patr1xcore due to a limited disk space on OVH VPS it's a bit tricky to deploy the image there. This is why I suggest to rebuild your VM with fresh ubuntu, then use wipefs inside rescue, download ISO locally (on your PC) and finally transfer it over SSH as mentioned in the gist.

cat FreeBSD-14.0-RELEASE-amd64.raw.xz | ssh [email protected] "xz -dc | dd of=/dev/sdb bs=1M"

if you want to do it inside rescue environment you might want to try something like:

wget -O - https://download.freebsd.org/releases/VM-IMAGES/14.0-RELEASE/amd64/Latest/FreeBSD-14.0-RELEASE-amd64.raw.xz | sudo dd of=/dev/sdb

however I haven't tested it so I can't tell if it's going to work this way

@patr1xcore
Copy link

@patr1xcore due to a limited disk space on OVH VPS it's a bit tricky to deploy the image there. This is why I suggest to rebuild your VM with fresh ubuntu, then use wipefs inside rescue, download ISO locally (on your PC) and finally transfer it over SSH as mentioned in the gist.

cat FreeBSD-14.0-RELEASE-amd64.raw.xz | ssh [email protected] "xz -dc | dd of=/dev/sdb bs=1M"

if you want to do it inside rescue environment you might want to try something like:

wget -O - https://download.freebsd.org/releases/VM-IMAGES/14.0-RELEASE/amd64/Latest/FreeBSD-14.0-RELEASE-amd64.raw.xz | sudo dd of=/dev/sdb

however I haven't tested it so I can't tell if it's going to work this way

I have installed Ubuntu on Virtual Box, downloaded FreeBSD locally, used that command and it worked!
It boots fine now and everything works.

Thank you for your help, highly appreciated. :)

@c0m4r
Copy link
Author

c0m4r commented Apr 11, 2024

I'm glad I could help

@kolmidad
Copy link

From my experience it seems that all or some VPS now use /21 (255.255.248.0) ipv4 subnet mask.
Anyway, this article was very useful. Thanks for it

@Veence
Copy link

Veence commented Jun 16, 2025

Works like a charm. Many thanks for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment