At work we had a spare dev machine which we wanted to set up to run a Gitlab runner to run our Continuous Integration (CI) for our repositories. Rather than use the whole machine, we decided to create a VM to run it - allowing it its own little space.

Virtual Machines are exactly just that. Programs running inside a VM have no idea they are in a VM - they think they are in a physical machine. Many “cloud” servers today are VMs hosted on mega servers.

We previously had this set up with Vagrant, but that was using a lot of processing power and space for something no-one at work understood. We have an existing Xen server setup, so I took it upon myself to reconfigure the server with this.

These instructions are for Debian, and they worked for me. It is recommended you know command line and at least a little about command line and servers

Install Xen

Xen play nicely with Vagrant (as they do the same thing), so if you are replacing Vagrant with Xen, ensure you have the data from your Vagrant Virtual Machines backed up. Vagrant won’t boot once Xen is installed.

All of the instructions are on the Debian Wiki

$ apt-get install xen-system

Note: Ensure you follow the instructions under the Networking heading on the Wiki page. A Bridge is required for the VMs to connect to the internet - this details setting it up.

Use Xen

There are plenty of comments for Xen, which all need to be run as root. These can be seen with xl help.

Create a VM

To create a new image, you use the xen-create-image command. It can take several arguments, but a common command to create a VM with 8gb “hard-drive” and 1gb RAM would be the following:

$ xen-create-image --hostname=mikevm --dhcp --size=8G --memory=1G

Here I have made a vm with the imaginative name of mikevm - keep a note of what you put here as it is used in the following commands.

A recommended additional parameter is the --password= one - this allows you to set a root password for accessing the machine. If you omit one, it will be output on the command line once the machine has been created

This command makes a file in /etc/xen/mikevm.cfg - feel free to have a look at this file to see what is in it.

#mike street #python #javascript #machine learning

Getting started with Xen - setting up virtual machines - Mike Street .
1.30 GEEK