Jon Atkinson

Jon Atkinson

Installing Arch on a Vultr VPS

Abstract

I have been happy using Vultr as my VPS provider for a few months now. Vultr offer a very flexible system of ISO upload before the first boot, which means essentially unlimited options when choosing the operating system for a new VPS (there is also a large library of ISO images to chose from; only occasionally have I actually uploaded my own).

However, booting a fresh ISO on a VPS can be a challenge; the hardware and devices exposed to the VPS are usually unfamiliar. These are my steps for installing Arch after the VPS has been provisioned by Vultr, and you have a working VNC connection to the console.

This assumes a familiarity with Arch. Don't forget the installation guide is the most comprehensive resource if you get stuck.

General Checks

Check that networking has come up correctly in the live ISO environment:

# ping -c 1 google.com

Update the system clock.

# timedatectl set-ntp true

Update the Arch keyring.

# pacman -Sy archlinux-keyring

Disk Partitioning

Check the available block devices. Your disk will be available as vda or similar, but adapt the following as required. Once you have identified the disk, use fdisk to partition.

# lsblk
# fdisk /dev/vda

Create a new, full-disk partition by pressing N, and using the default values for each question. Your new partition will be available as /dev/vda1/ once complete.

Write the partition table with W.

Finally, we need to create a new filesystem on the disk and mount it. I use ext4, because I'm unfamiliar with btrfs. Your research might indicate that btrfs is more appropriate for your needs.

# mkfs-ext4 /dev/vda1 
# mount /dev/vda1 /mnt

Bootstrapping

Now it's time to bootstrap the system with the base metapackage. This may take a while. If you plan on compiling a lot of code, it might be worth also installing base-devel at this point.

# pacstrap /mnt base
# pacstrap /mnt base-devel

Soon, we are going to chroot into the new system. First, we need to create an fstab:

# genfstab /mnt >> /mnt/etc/fstab

Now, we will switch over to the new system:

# arch-chroot /mnt

Basic Configuration

Now we are chrooted into the system, set the timezone and sync the clock:

# ls /usr/share/zoneinfo/Europe/
# ln -sf /usr/share/zoneinfo/Europe/London /etc/localtime
# hwclock --systohc

Set the root password:

# passwd

Set the system locale to UTF-8. Visit locale.gen and uncomment en_GB.UTF-8 UTF-8, then set the locale:

# vi /etc/locale.gen
# echo 'LANG=en_GB.UTF-8' > /etc/locale.conf

Networking

Now, find the currently active network adaptor. This is usually called ens3 or similar.

# ip addr

Write the configuration file:

# vi /etc/systemd/network/ens3.network

The content should be as follows:

[Match]
Name=ens3

[Network]
DHCP=ipv4

Enable DHCP, DNS and setup resolv.conf:

# systemctl enable systemd-networkd
# systemctl enable systemd-resolved
# ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf

Set the system hostname

# echo 'server.domain.com' > /etc/hostname

Install the bootloader

Install grub, and write a configuration file.

# pacman -S grub
# grub-install --target=i386-pc /dev/vda
# grub-mkconfig -o /boot/grub/grub.cfg

Reboot

Now, exit the chroot, and reboot the system.

# exit
# systemctl poweroff

Now, in the Vultr control panel, unmount the ISO, and boot the system again. Reconnect the VNC console.

Post-Boot Setup

Assuming the system has booted successfully (if it hasn't, then re-insert the ISO, remount /dev/vda1, and reactivate the chroot to investigate), then login as root.

Next, create a new user, and setup sudo:

# useradd --create-home <yourusername>
# passwd <yourusername>
# pacman -S sudo
# visudo

Find the appropriate section of /etc/sudoers, and add something like this:

<yourusername> ALL=(ALL) ALL

Now, logout as root and login again as your newly created user.

# exit

Next, install SSH and edit the configuration file to enable a port. Typically this will be port 22.

$ sudo pacman -S openssh
$ sudo vi /etc/ssh/sshd_config

Finally, enable SSH:

$ sudo systemctl enable --now sshd

You should now be able to login via SSH (root is denied by default). You can continue your onward configuration from there.