Arch Linux on a new VPS, Part 2
In my previous post, I talked a bit about my hosting company and the Linux distribution I use for my servers. In this post, I’ll share some details you should know before using Arch on a VPS.
First, it’s important to know that there are several ways for a hosting company to split a single physical server into multiple virtual machines. While the goal is the same – to share one server’s resources across many VMs – the differences are important, particularly for a rolling-release distribution like Arch.
The first type is a true virtualization product, like Xen, VMWare, and Hyper-V. These products partition a server into several distinct VMs that are completely isolated from one-another. Because each VM is a “real” server from the software’s perspective, nothing special needs to be done to make an operating system work. Typically, there are special drivers available to increase the VM’s performance but they are not required if you’re just getting things installed and running.
The other type is more like a container than a true virtual machine, OpenVZ being the most common example. In this type, all VMs share the same kernel and require some modification to work in the virtual environment. While the lack of isolation and the sharing of resources might sound like a bad idea, there is one huge up-side: performance. The speed of an OpenVZ VM is very close to a physical server, and each can share some of the unused resources from other VMs on the same server.
BuyVM uses OpenVZ, which is how they can offer 512MB of dedicated memory and a “burst” amount of 1024MB. Your VM is guaranteed to see at least 512MB of RAM at any given time, but it could actually have more available if others are not using it. I knew that Arch Linux would need to have a special kernel and core library (glibc) in order to work properly in an OpenVZ environment, so I was worried that I would be building my own packages. However, like everything else in this distribution, the community has already solved the problem.
The first thing to do is to update the system’s packages. This is normally done by issuing the command:
pacman -Syu
However, this will update glibc with the current mainline distribution’s version, breaking the server. If you do this, you will start getting a lot of console messages that say:
Fatal: kernel too old
So, to solve this issue, you need to edit the pacman configuration file (/etc/pacman.conf) and add the following two lines above the section labelled “[core]“:
[glibc-vps]
Server = http://dev.archlinux.org/~ibiru/openvz/glibc-vps/i686
Save the file, and then run the “pacman -Syu” command as root. The first thing the installer will ask you is if you want to update pacman itself before doing anything else. Say no for the moment, we’ll get to that next. After answering no to pacman, all of the packages will be downloaded and updated and the most current version of the OpenVZ glibc will be installed.
Next, we should update pacman so that it stops bothering us every time we install something. To do this, simply run the following command:
pacman -S pacman
After it downloads and installs, we need to update its configuration file so that it never automatically updates glibc as part of a dependency of another application. To do this, edit pacman’s configuration file again and look for the line that says “IgnorePkg”. Add glibc to the ignore list:
# Pacman won’t upgrade packages listed in IgnorePkg
IgnorePkg = glibc
That’s it! From this point we have a current Arch release running on a fast VM for $6/month. It’s a great deal, and a terrific learning experience. From here, I’d suggest looking at some of the other installation documents for setting up a web server, a database server, and perhaps PHP or Ruby on Rails. I’ve got some links below to get you started.
Thanks for reading!
Arch on OpenVPS: https://wiki.archlinux.org/index.php/VPS_Repo
Securing SSH with sshguard: https://wiki.archlinux.org/index.php/Sshguard
Installing the lighttpd web server (and PHP / Ruby): https://wiki.archlinux.org/index.php/Lighttpd
Installing mysql: https://wiki.archlinux.org/index.php/MySQL