Install Arch Linux On OVH VPS
OVH recently announced that it will not offer the option of Arch Linux and FreeBSD for new installations. Although they recommend that you upload your own image if you are using its Public Cloud, this option is not available to VPS users.
Not a problem though. There are a few ways to install any OS you want and they seem ok with it.
Use a cloud image
I have tested this method with Arch and Debian bullseye images and everything worked fine, including IPv6 configured out of the box. The following steps describe an Arch installation but, with small adjustments, they should work for other distributions as well.
Install any available distribution such as e.g. Debian.
Log in the manager and reboot in rescue mode. The rescue system is Debian based and includes backports and ZFS packages if you ever need them.
lsblk to orient yourself. The Debian based rescue disk should be mounted at
/dev/sda while your target disk is at
Make some extra room for the image:
mkdir /tmp/mnt mount -t tmpfs tmpfs /tmp/mnt cd /tmp/mnt
Download the image with wget:
- Arch Linux https://mirror.pkgbuild.com/images/latest/, use
- Debian https://cloud.debian.org/images/cloud/bullseye/daily/latest/ use
apt install qemu-utils
Overwrite your target disk /dev/sdb with the image as shown in the arch wiki. Notice we are overwriting the whole disk, not just a partition:
qemu-img convert -f qcow2 -O raw Arch-Linux-x86_64-cloudimg-20210315.17387.qcow2 /dev/sdb
The Arch Linux image uses a
GPT partitioning scheme, a btrfs partition compressed with zstd and a BIOS compatibility partition.
To make sure you are able to login after reboot, it’s a good idea to setup a user with
sudo abilities and a known password. You may also copy your ssh public key manually.
sfdisk -l /dev/sdb mount -t btrfs /dev/sdbX /mnt chroot /mnt useradd -m -s /bin/bash -G wheel arch passwd arch echo "arch ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/arch
Finally use the manager to reboot the virtual machine in normal mode.
Cloud images contain
cloud-guest-utils which should take of resizing the partition table to fill the disk, setup networking etc. If for some reason you can’t connect with ssh, you can still try KVM to login.
If you got so far, then it’s time to secure the installation:
- configure ssh to only use public key authentication rather than password authentication
- setup a firewall
OVH recommends that
qemu-guest-agent are installed when using a custom image.
cloud-guest-utils are already installed, so:
sudo pacman -S qemu-guest-agent sudo systemctl enable --now qemu-guest-agent.service
Have a look at
- To have KVM console work, we need to add
console=ttyS0to boot parameters.
- To improve performance, you may be interested in disabling compression by removing
- Provide some entropy to the kernel’s random number generator. You may decide that you’d rather trust the CPU manufacturer’s random number generator rather than get warnings in boot messages about using an uninitialized
These are just some recommendations. So, let’s modify
/etc/default/grub to look like this:
GRUB_CMDLINE_LINUX_DEFAULT="random.trust_cpu=on" GRUB_CMDLINE_LINUX="net.ifnames=0 console=ttyS0"
And then we can apply the changes.
sudo grub-mkconfig -o /boot/grub/grub.cfg sudo reboot sudo btrfs filesystem defragment -r /
Perhaps you are interested in converting the system to use a flat hierarchy of subvolumes by using steps similar to the ones described here.
Here is a benchmark comparing the performance of Postgresql on btrfs and other filesystems.