Mageia 4 Xen Server

mageia logo

A quick guide for a working Xen hypervisor (Dom0) on a Mageia 4 host.

Minimal installation for a server

Fetch a network install iso (64 bit!)

I chose a Text installer, but do a graphical install if you prefer. We are doing a minimal install.

  • Install from HTTP (choose your favorite mirror)
  • Desktop : custom
  • uncheck everything
  • next screen (“Type of install”), use default choices
  • bootloader : I prefer GRUB2

Installation finished, reboot, login as root.


Set hostname

# hostnamectl set-hostname mgaserv

Install some server-related and useful packages

# urpmi kernel-server-latest htop mlocate nano wget sshd

Firewall is enabled by default on Mageia. I suggest we disable it right now

# drakfirewall

Allow everything

Note : to temporarily disable the firewall

# shorewall clear

Start ssh daemon

# systemctl start sshd && systemctl enable sshd

(Now you can open a remote ssh session)

(optional) Allow root login via ssh

# sed -e 's/PermitRootLogin No/PermitRootLogin Yes/1' -i.bak /etc/ssh/sshd_config

# systemctl restart sshd

Install Xen Hypervisor

# urpmi --no-suggests xen xen-doc qemu

Choose Xen kernel at boot

# drakboot

(reboot system)

# reboot

We use the new xl tools to control our Xen hypervisor

# man xl

The xen daemons should be started automatically by systemd

# systemctl | grep xen

Since we will be using the xl xen interface, we need to shutdown the xend daemon

# systemctl stop xend; systemctl disable xend

We need to create a network bridge for use with Xen

(It might be useful to disable the firewall *before* creating the bridge)

# brctl addbr xenbr0

# brctl addif xenbr0 <your_network_interface_name>

(use ifconfig -a to show all interfaces)

# dhclient xenbr0

(if your network has a dhcp server)

Note : if the firewall is not disabled your ssh session will be blocked, you will need to run drakfirewall again, to allow xenbr0)

We also need our bridge interface to be created at boot, let’s edit some files in /etc/sysconfig/network-scripts

# nano /etc/sysconfig/network-scripts/ifcfg-<your_ethernet_interface_name>







And the bridge interface

# nano /etc/sysconfig/network-scripts/ifcfg-xenbr0





Make sure ifcfg-xenbr0 is executable

# chmod +x /etc/sysconfig/network-scripts/ifcfg-xenbr0

Let’s create our first guest virtual machine (Xen DomU), a fully-virtualized (HVM) Mageia Linux 64bit guest

First download a Mageia network install iso (you may choose another mirror : )

# mkdir -p /root/iso && pushd /root/iso && curl -o boot64.iso && popd

Create a disk image for our guest

# qemu-img-xen create mga-sda.img 2G

Create xl config file for this guest domain

# cat >/etc/xen/xl-mga-guest.hvm <<EOF

builder = "hvm"

boot = "d"

name = "mga-guest.hvm"

memory = 512

pae = 1

vcpus = 1

vif = [ '' ]

disk = [ '/root/mga-sda.img,,xvda,rw', '/root/iso/boot64.iso,,hdc,cdrom' ]

#sdl = 1

# enable VNC access to all (use only on trusted networks!)

vnc = 1

vnclisten = ""

vncpasswd = "YOURPWD!"

#keymap = "fr"

vga = "stdvga"


For more help with XL domain configuration

# man xl.cfg

Finally create (and start) the guest VM

# xl help create

(to show some help)

# xl create /etc/xen/xl-mga-guest.hvm

In case the creation fails, verify that your are actually running the Xen kernel

# journalctl -b|grep -i xen


# xen-detect

If this is not the case, reconfigure your bootloader with drakboot, use *GRUB2 with graphical menu*, and reboot, you should now have a Xen entry in the menu

(set it as default while you are at it)

NOTE : Mageia HVM guest with the network install iso seems to crash & reboot while loading the kernel, I was unable to go past the bootloader. (TODO : test with a full Mageia4 LiveCD)

But the HVM guest worked fine when using another, Debian-based, Linux iso.

In any case, you should be able to open a VNC connection to your guest at vnc://<your_xen_server_host>:5900

(remember console access is not available for HVM guests)

Now, we can create a second guest, a paravirtualized Debian Linux machine.

Files needed for such a system can be found at

Download the 3 files :

# mkdir -p /root/debian && cd /root/debian && wget{debian.cfg,initrd.gz,vmlinuz}

Create a new disk image

# qemu-img-xen create /root/debian-sda.img 2G

Edit supplied Debian config file

# cp debian.cfg /etc/xen/debian-guest.pv && nano /etc/xen/debian-guest.pv

Change the following lines :

kernel = "/root/debian/vmlinuz"

ramdisk = "/root/debian/initrd.gz"

memory = 256

name = "debian-guest01"

disk = ['/root/debian-sda.img,,xvda,w']

Important : 128M of RAM is not enough for the Debian installer, so give it at least 256.

Create guest

# xl create /etc/xen/debian-guest.pv -c

Now install your Debian guest using the debootstrap installer.

Once your Debian guest installation is finished, you need to edit your xl config file for the guest to be able to boot.

First properly shutdown our guest with

# xl shutdown debian-guest01

Then edit config

# nano /etc/xen/debian-guest.pv

Just read the instructions for booting in the template ( see section “# TO BOOT INSTALLED SYSTEM” )

Basically, comment the kernel= and ramdisk= lines, and uncomment the bootloader=”pygrub” line.

Done, restart and enjoy your Debian guest

# xl create /etc/xen/debian-guest.pv -c

What about a Mageia PV guest?

We need the kernel and initrd files from the Mageia iso image

# cd && mkdir {mageia,tmpiso} && mount -o loop iso/boot64.iso tmpiso && cp -av tmpiso/isolinux/x86_64/{vmlinuz,all.rdz} mageia/

We will use the Debian guest template and modify it for Mageia

# cp /etc/xen/debian-guest.pv /etc/xen/mga-guest.pv && nano /etc/xen/mga-guest.pv

Change the following lines :

kernel = "/root/mageia/vmlinuz"

ramdisk = "/root/mageia/all.rdz"

# we use the text installer (the graphical one doesn't seem to work in a guest)

extra = "text"

# at least 256M of RAM

memory = 256

name = "mga-guest01"

disk = [ '/root/mga-sda.img,,xvda,rw', '/root/iso/boot64.iso,,hdc,cdrom' ]

# for VNC access (use only on trusted networks)

vfb = [ 'type=vnc,vnclisten=,vncpasswd=YOURPWD!,keymap = fr' ]

Finally create your Mageia PV guest and follow the text installer

# xl create /etc/xen/mga-guest.pv -c

You should be able to open a VNC connection to your guest at vnc://<your_xen_server_host>:5900

When installation is finished, shutdown the guest and edit your xl file so that the system is bootable (same thing as above for the Debian guest)

And finally restart your Mageia PV guest.

Or a NetBSD PV guest?

Piece of cake!

Fetch the necessary NetBSD kernel files

# VER="6.1.3" mkdir -p /root/netbsd/ && pushd /root/netbsd && wget"$VER"/amd64/binary/kernel/netbsd-{XEN3_DOMU.gz,INSTALL_XEN3_DOMU.gz} && popd

Create the img file (RAW only, otherwise formatting the disk in NetBSD’s installer will likely fail!)

# qemu-img create -f raw /root/netbsd.img 2G

Our xen config file

# cat >/etc/xen/netbsd-guest.pv <<EOF
# NetBSD kernel for installation
kernel  = "/root/netbsd/netbsd-INSTALL_XEN3_DOMU.gz"
# NetBSD kernel to be booted after installation
#kernel  = "/root/netbsd/netbsd-XEN3_DOMU.gz"
memory = 512
name = "netbsd-guest01"
vif = ['']
disk = [ '/root/netbsd.img,,xvda,rw' ]
vfb = [ 'type=vnc,vnclisten=,vncpasswd=YOURPWD!,keymap = fr' ]

Let's start the installation

# xl create /etc/xen/netbsd-guest.pv -c

The NetBSD installer should appear on your console. We are doing a netinstall, so let’s start the network before doing anything
Go to “e: Utility menu” then “c: configure network”.
Network is up, go back to main menu and start installing to hard disk.
When prompted for an installation media, choose a FTP or HTTP (remember to choose a mirror near your location for faster downloads)

Install finished, stop the domU
# halt -p
(from within the domU!)
# xl shutdown netbsd-guest01
(from your Dom0)

Now to boot our newly installed NetBSD domU, let’s change our configuration
# nano /etc/xen/netbsd-guest.pv

kernel  = "/root/netbsd/netbsd-XEN3_DOMU.gz"

Finally restart your domU and enjoy your NetBSD system ( man afterboot / )
# xl create /etc/xen/netbsd-guest.pv -c

Helpful links

TODO : spice

TODO : lvm


One thought on “Mageia 4 Xen Server

  1. Great little resource on Xen. I when through the whole process of trying to port the Citrix opensource xenserver rpms over to Mageia3/64 bit and it appeared to have worked. Unfortunately I had to give that machine up to a co-worker who wiped it and installed Windows on it. After having gone through all the with Xen, Xapi, Citrix Xenserver, ocalm, it’s good to see a location specific about Mageia4 and Xen, Xapi, Xenserver …

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s