Creating Xen VM (DomU) and change its configuration

You have physical server with Linux (eg. Debian). You have XEN Hypervisor installed and configured to work with two networks (public and LAN) available in bridges (xenbr0 and xenbr1). For storage I suggest using LVM partitions for easy creation and modyfication disc partitions for virtual machines.

Time to create first virtual machine. In Xen virtual machine (VM) is called DomU (User Domain).

xen-create-image –hostname=mysql.lan  –size=10G  –ip=1.2.3.4 –vifname=mysql.0 –vcpu=4 –gateway=1.2.3.1 –netmask=255.255.255.0 –dist=xenial

Before I explain the above command, let’s start with the configuration utility xen-tools used to create new virtual machines.

apt-get install xen-tools

I suggest to configure xen-tools for making some common configuration for all created virtual machines. You can make some changes in /etc/xen-tools/xen-tools.conf. All of this settings you can overwrite during use command „xen-create-image” or later, by modyfiyng VM config file.

lvm = data #your LVM VG group 
install-method = debootstrap #default for Ubuntu and Debian
nameserver = 8.8.8.8 #because you want to add static DNS
bridge = xenbr0 #default network bridge, later you will change it
pygrub = 1 #VM kernel run from VM, not from XEN host!!
arch=amd64  #best and default architecture if you have amd64 physical server

Now you can add first virtual machine. Just use one command. Every parameter begins with double minus:

xen-create-image \
--hostname=mysql.lan \
--lvm=data --size=10G –-fs=ext4 \
--swap=1G \
--memory=2048M \
--pygrub --vcpu=4 \
--vifname=mysql.0 \
--bridge=xenbr0 \
--ip=1.2.3.4 \
--netmask=255.255.255.0 \
--gateway=1.2.3.1 \
--nameserver=8.8.8.8 \
--dist=jessie

By default only one network interface on one partition „/” is created, but you can add more later. As a result you will see information about created virtual server.

Installation Summary
---------------------
Hostname        :  mysql.lan
Distribution    :  jessie
MAC Address     :  00:16:3E:21:3C:12
IP Address(es)  :  1.2.3.4
SSH Fingerprint :  74:08:1a:de:87:4e:84:ec:f6:12:5a:fe:43:c6:b6:45 (DSA)
SSH Fingerprint :  76:88:70:45:08:65:eb:12:d9:c2:34:bf:e0:2d:4e:67 (ECDSA)
SSH Fingerprint :  31:0f:91:56:16:5c:43:79:f7:90:b4:56:39:23:90:89 (ED25519)
SSH Fingerprint :  75:ea:ed:9c:ac:bc:9b:21:fe:36:1a:8e:78:6e:a5:10 (RSA)
Root Password   :  f2GPNbHkjhg87HHGFfayd6Y

By default, created VM it is not turned on – its good because sometimes you will need to make some changes in VM config file (add more disc or partitons, second network interface, etc.). Now you can run your virtual machine.

cd /etc/xen/
xl create mysql.lan.cfg

And you can log into virtual machine using SSH. If you want tologin to VM console you can use „-c” option during „xl create” or later just use:

xl console mysql.lan

For disconnecting from console use „ctrl+]”. If you have terminal/shell problems after disconnecting (no new lines, etc), type „clear” (shortcut „ctrl+l”) or „reset” – this commands helps with displaing problems.

Ten wpis został opublikowany w kategorii Linux, Xen. Dodaj zakładkę do bezpośredniego odnośnika.