Arch Linux on a VPS

From ArchWiki

From Wikipedia:Virtual private server:

Virtual private server (VPS) is a term used by Internet hosting services to refer to a virtual machine. The term is used for emphasizing that the virtual machine, although running in software on the same physical computer as other customers' virtual machines, is in many respects functionally equivalent to a separate physical computer, is dedicated to the individual customer's needs, has the privacy of a separate physical computer, and can be configured to run server software.

This article discusses the use of Arch Linux on Virtual Private Servers, and includes some fixes and installation instructions specific to VPSes.

Official Arch Linux cloud image

Arch Linux provides an official cloud image as part of the arch-boxes project. The image comes with Cloud-init preinstalled and should work with most cloud providers.

The image can be downloaded from the mirrors under the images directory. Instructions for tested providers is listed below:

Provider Locations Note
Digital Ocean Global
  1. Find the cloud image on a mirror, ex: https://mirror.pkgbuild.com/images/latest/Arch-Linux-x86_64-cloudimg-yyyymmdd.12345.qcow2 (check here for the latest link: https://mirror.pkgbuild.com/images/latest/)
  2. Add the image as a custom image by importing it
  3. Create a new VM from the custom image
  4. SSH to the VM: ssh root@<ip>
Hetzner Cloud Nuremberg, Falkenstein (Germany), Helsinki (Finland)
  1. Create a new VM with this user data:
    #cloud-config
    vendor_data: {'enabled': false}
    The vendor_data from Hetzner overrides the distro and sets the default user to root without setting disable_root: false, meaning you can not login
  2. Boot the VM in rescue mode
  3. SSH to the VM and download the cloud image from a mirror, ex: curl -O https://mirror.pkgbuild.com/images/vyyyymmdd.12345/Arch-Linux-x86_64-cloudimg-yyyymmdd.12345.qcow2
  4. Write the image to the disk: qemu-img convert -f qcow2 -O raw Arch-Linux-x86_64-cloudimg-yyymmdd.12345.qcow2 /dev/sda
  5. Reboot the VM
  6. SSH to the VM: ssh arch@<ip>
Linode Multiple international locations
  1. Create a new VM and select Arch as the distro (to use the Linode-provided image, stop here; otherwise proceed with the rest of the steps)
  2. Boot the VM in rescue mode
  3. Connect to the VM via the Lish console and download the basic image from a mirror, ex: curl -O https://mirror.pkgbuild.com/images/latest/Arch-Linux-x86_64-basic-yyyymmdd.0.qcow2
  4. Install the qemu-utils package: apt update && apt install qemu-utils
  5. Write the image to the disk: qemu-img convert -f qcow2 -O raw Arch-Linux-x86_64-basic-yyyymmdd.0.qcow2 /dev/sda
  6. In the Linode manager, go to the VM's configurations menu and edit the config to change the kernel option to "Direct Disk"
  7. Reboot the VM
  8. SSH to the VM: ssh arch@<ip>
Proxmox N/A
  1. Create a new VM
  2. Select "Do not use any media" in OS section.
  3. Remove created hard disk from your VM after VM creation completes.
  4. Add the downloaded image to your VM using qm importdisk, ex:
    qm importdisk 100 Arch-Linux-x86_64-cloudimg-20210315.17387.qcow2 local
  5. Add a cloudinit drive and make your configurations in Cloud-Init section.
  6. Start the VM!

Providers that offer Arch Linux

Tango-edit-clear.pngThis article or section needs language, wiki syntax or style improvements. See Help:Style for reference.Tango-edit-clear.png

Reason: Inconsistency, some language issues (Discuss in Talk:Arch Linux on a VPS)
Warning: We cannot vouch for the honesty or quality of any provider. Please conduct due diligence before ordering.
Note: This list is for providers where Arch Linux can be installed in a supported way. This excludes any container-based hosting such as LXC or Docker as well as OpenVZ.
Provider Archiso release Virtualization Locations Notes
BuyVM 2017.08.01 KVM Buffalo, (US-NY); Las Vegas, (US-NV); Luxembourg, Germany (DE) Once purchased, use Stallion control panel to install Arch manually from ISO.
CloudVIP Latest KVM Brussels, Belgium French site and support.
Contabo Latest KVM Germany Only place to get 500 GB for 7€ - Decent speed. Other cheaps plans add snapshots, which is useful if you VPS runs a rolling release distro.
Edis 2019.02.01 KVM Multiple international locations. Also offer dedicated server options as well as an "off-shore" location at the Isle of Man (IM). Requires mounting an Arch ISO for a full manual install.
Hetzner 2020.06.01 KVM Nuremberg, DE; Falkenstein, DE; Helsinki, FI You cannot choose Arch Linux directly on the order form. Order Ubuntu or something first, then go to ISO Images, mount Arch Linux, reboot server, and log in to web console to complete installation.
Linode Latest KVM Multiple international locations Linode instances are configured to run Arch's kernel by default. Linode provides custom kernels which can be selected in the manager settings. There are also community-supported kernels in the AUR, such as linux-linodeAUR.
Netcup 2020.09.01 KVM Germany (DE) German language: Netcup
MedHaHosting Latest KVM Buffalo, NY, USA; Atlanta, GA, USA; Chicago, IL, USA; Los Angeles, CA, USA Arch Linux available on request. Many Linux and Windows hosting options.
MonoVM Latest VMware USA - Canada - Netherlands - Germany - UK - France - Denmark VMware Based VPS Server Provider.
Proplay Latest KVM Germany (DE) (German language site only)
Rackspace Cloud 2013.6 Xen Multiple international locations[dead link 2020-12-19 ⓘ] Billed per hour. Use their "next gen" VPSes (using the mycloud.rackspace.com panel); the Arch image on the first gen Rackspace VPSes is out of date.
RamNode 2016.01.01 SSD and SSD Cached: KVM Alblasserdam, NL; Atlanta, GA-US; Los Angeles, CA-US; New York, NY-US; Seattle, WA-US You can request Host/CPU passthrough with KVM service.[1] Frequent use of discount promotions.[2], Must install Arch manually from an ISO using VNC viewer.
SeedVPS Latest KVM Amsterdam, Netherlands Linux VPS and Windows VPS Hosting in The Netherlands (NL). Newer ISO can be requested by opening a support ticket.
Server Cheap Latest KVM Chicago, Illinois, USA Arch Linux available on request. Windows, BSD, and many Linux distribution hosting options.
TransIP latest KVM Amsterdam, NL For latest image, submit ticket. Also registrar.
Vultr Latest KVM Multiple International locations When deploying a new server just select the Arch install ISO from Vultr ISO Library. Then just manually run through the standard Arch installation guide.
Misaka.io / zeptoVM Latest KVM Multiple International locations Images are built every 24 hrs
VPSDime Latest KVM Dallas, Seattle, Los Angeles, New Jersey, London, Amsterdam Premium VPS line supports manual install.

Providers with Community provided Arch Linux support

Warning: We cannot vouch for the honesty or quality of any provider. Please conduct due diligence before ordering.
Note: Arch Linux is not officially supported by these providers. The images and scripts listed here are created by the community.
Provider Installation Type Locations Notes
Amazon Web Services Custom Images Global
Digital Ocean Official Arch cloud image, Conversion Script or Custom Image Global IPv6 does not work with custom images, but works with conversion script
Google Cloud Platform Custom Image Global

Installation

See QEMU#Preparing an Arch Linux guest for KVM.

Xen HVM might also work the same way.

OpenVZ

Installing the latest Arch Linux on any OpenVZ container provider

Warning: Please refer to the warning about the older kernel version and systemd at the top of the page, and note the workaround for OpenVZ 7 below.

It is possible to directly copy an installation of Arch Linux over the top of a working OpenVZ VPS. This tutorial explains how to create a basic installation of Arch Linux with pacstrap (as used in a standard install) and then replace the contents of a target VPS with it using rsync.

This process (with minor modification) also works to migrate existing Arch installations between various environments and has been confirmed to work in migrating from OpenVZ to Xen and from Xen to OpenVZ. For an install to Xen, other hardware-virtualized platforms, or even to physical hardware, extra steps (basically running mkinitcpio and installing a boot loader) are needed.

Prerequisites
  • A working Arch Linux installation
    • To keep things simple, it should match the architecture you want to install on your VPS (x86_64 or i686).
    • To build from other distributions, arch-bootstrap.sh can be used in place of pacstrap.
  • The arch-install-scripts, rsync, and openssh packages from the official repositories
    • SSH is not strictly required, but rsync over SSH is the method used here.
  • A VPS running any distribution, with rsync and a working SSH server
    • Its architecture (x86_64 or i686) does not matter as long as the OpenVZ installation can support your target architecture.
  • OpenVZ's serial console feature (usually accessible via your provider's control panel)
    • Without this, any network configuration for the target VPS will have to be done immediately after the "Build" step below.
Building a clean Arch Linux installation

As root, build the installation (optionally replacing build with your preferred target directory):

# mkdir build
# pacstrap -cd build

Other tweaks for the pacstrap command:

  • -C custom-pacman-config.conf - Use a custom pacman configuration file. By default, pacstrap builds according to your local pacman.conf. This determines the architecture (i686 or x86_64) of the build, the mirror list, etc.
  • -G - Prevent pacstrap from copying your system's pacman keyring to the new build. If you use this option, you will need to run pacman-key --init and pacman-key --populate archlinux in the Configuration step to set up the keyring.
  • -M - Prevent pacstrap from copying your system's pacman mirror list to the new build.
  • You can pass a list of packages to pacstrap to add them to your install, instead of the default base group. For example: pacstrap -cd build base openssh dnsutils gnu-netcat traceroute vim
Preparing the Arch build for use on an OpenVZ 7 container

OpenVZ 7 will fail to start a container if some expected network configuration files do not exist. The easiest way to get around this is as follows:

  1. Create the OpenVZ 7 container as Debian 8 (Debian 9 would probably work as well).
  2. Create the required blank network configuration files inside the Arch build, as follows:
# mkdir build/etc/network
# touch build/etc/network/interfaces
# mkdir -p build/etc/resolvconf/resolv.conf.d
# touch build/etc/resolvconf/resolv.conf.d/base
Replacing everything on the VPS with the Arch build

Replace all files, directories, etc. on your target VPS with the contents of your build directory (replacing "YOUR.VPS.IP.ADDRESS" below):

Warning: Be careful with the following command. By design, rsync is very destructive, especially with any of the --delete options.
# rsync -axH --numeric-ids --delete-delay -e ssh --stats -P build/ YOUR.VPS.IP.ADDRESS:/

Explanation of options:

  • -a - Required. Preserves timestamps, permissions, etc.
  • --delete - Required. Deletes anything in the target that does not exist in the source
  • -x - Important. Prevents the crossing of filesystem boundaries (other partitions, /dev, etc.) during the copy
  • -H - Important. Preserves hardlinks
  • --numeric-ids - Important. Does not assign user/group ownership of files based on matching user and group names and instead uses the numeric IDs directly, ensuring proper file ownership on the target system
  • --delete-delay - Recommended. Enables alternate deletion mode which waits to delete anything until the synchronization is otherwise complete, which may reduce the risk of a slow transfer causing the target VPS to lock-up
  • -e ssh - Recommended. Uses rsync over SSH (recommended for simplicity compared to setting up an rsync server)
  • -P - Recommended. Shows partial progress information during transfer
  • --stats - Recommended. Shows transfer statistics at the end
Configuration
  1. Reboot the VPS externally (using your provider's control panel, for example).
  2. Using OpenVZ's serial console feature, configure the network and basic system settings (ignoring fstab generation and arch-chroot steps).
    • If you do not have access to the serial console feature, you will need to preconfigure your network settings before synchronizing Arch to the VPS.
    • On some VPS configuration you will not have a gateway to connect to, here is an example netctl configuration for this setup. It configures static IP addresses and default routes on venet0 and uses Google Public DNS.
/etc/netctl/venet
Description='VPS venet connection'
Interface=venet0
Connection=ethernet

IP=static
Address=('192.0.2.42/32')
Routes=('default')

IP6=static
Address6=('2001:db8::1234:5678/128')
Routes6=('default')

DNS=('2001:4860:4860::8888' '2001:4860:4860::8844' '8.8.8.8' '8.8.4.4')