Difference between revisions of "Xen installation"

From ERIKA WIKI
Jump to: navigation, search
Line 135: Line 135:
 
=== Install Windows OS on the Xen HVM Guest ===
 
=== Install Windows OS on the Xen HVM Guest ===
  
 +
By assuming the Windows iso is located in <code>/root/windows.iso</code>, it follows an example of configuration file, referred to as <code>windows.cfg</code> to enable the installation of Windows on the logical volume.
 +
 +
  name="win"
 +
  builder="hvm"
 +
 
 +
  memory=4096
 +
  vcpus=2 #2cpus
 +
 
 +
  #disk option
 +
  disk=['file:/dev/XenVolumeGroup/windows,hda,w', 'file://root/windows.iso,hdb:cdrom,r']
 +
  boot="dc"
 +
 
 +
  #networking
 +
  vif=['type=ioemu, bridge=xenbr0']
 +
 
 +
  #vnc or sdl
 +
  vnc=1
 +
  sdl=0
 +
 
 +
  stdvga=0
 +
  usb=1
 +
  usbdevice="tablet"
 +
  ide0="noprobe"
 +
  serial="pty"
 +
 
 +
  on_poweroff="destroy"
 +
  on_reboot="preserve"
 +
  on_crash="preserve"
 +
 +
Launch the following command to start the guest:
 +
  $ xl create windows.cfg
 +
 +
Then, the VNC display should be available on port 5900 of your dom0 IP, for instance using vncviewer:
 +
  $ vncviewer <dom0-ip-address>:5900
 +
 +
Then, proceed with Windows' installation. Once you have installed Windows by formatting the disk and by following the prompts the domain will restart. However, in order to prevent the booting from DVD, destroy the domain:
 +
  $ xl destroy win
  
 
=== Run Windows OS on the Xen HVM Guest ===
 
=== Run Windows OS on the Xen HVM Guest ===
 +
After installing the Windows on the logical volume, change the boot line in the config file (i.e., <code>windows.cfg</code>)
 +
  boot="c"'''
 +
 +
Then start the domain:
 +
  $ xl create windows.cfg
 +
 +
and reconnect with VNC to have access to the Windows GUI.

Revision as of 14:36, 14 May 2019

Introduction

The section contains the instruction to install Xen hypervisor on platform x86-64. Furthermore, it contains the procedure for running Windows OS under Xen hypervisor.

Xen Installation procedure

The following installation procedure aims at installing Xen RELEASE-4.11.0 from source. It has been performed on the platform x86-64 with one of the following operating system:

  • Ubuntu 16.04
  • Ubuntu 18.04.1 LTS

Build Dependencies
Install the following packages:

 # apt update && apt dist-upgrade #update/upgrade the kernel
 # apt install build-essential
 # apt install bcc bin86 gawk bridge-utils iproute2 
 # apt install libcurl4 libcurl4-openssl-dev bzip2 module-init-tools transfig tgif
 # apt install texinfo texlive-latex-base texlive-latex-recommended texlive-fonts-extra texlive-fonts-recommended
 # apt install pciutils-dev mercurial
 # apt install make gcc libc6-dev zlib1g-dev python python-dev python-twisted 
 # apt install libncurses5-dev patch libsdl-dev libjpeg-dev
 # apt install libvncserver-dev
 # apt install iasl libbz2-dev e2fslibs-dev git-core uuid-dev 
 # apt install ocaml ocaml-findlib libx11-dev bison flex xz-utils libyajl-dev
 # apt install gettext libpixman-1-dev libaio-dev markdown pandoc
 # apt install libc6-dev-i386
 # apt install lzma lzma-dev liblzma-dev #for rombios
 # apt install libsystemd-dev xorriso

Retrieve the GRUB version
The Xen installation strictly depends on the installed Grub version: grub-pc or grub-efi. In order to retrieve the grub version, launch the following command:

 $ dpkg --get-selections | grep grub

Retrieve Xen source
Clone the Xen repository and switch to the chosen version (i.e., RELEASE 4.11):

 $ git clone https://github.com/xen-project/xen.git
 $ cd xen
 $ git checkout RELEASE-4.11.0 -b RELEASE-4.11.0

In the following part of the tutorial, we refer to the Xen repository path as $XENPATH.

Configure
Configure:

 $ $XENPATH/configure --enable-systemd

In case of Xen EFI (as for example in Ubuntu 18.04.01), add the option --enable-targets=x86_64-pep as follows:

 $ $XENPATH/configure --enable-systemd --enable-targets=x86_64-pep

Build and install
Build all components (hypervisor, tools, docs, stubdomains, etc):

 $ cd $XENPATH
 $ make dist

Install (as root):

 # make install

Enable the Xen services
Reload dynamic libraries:

 # /sbin/ldconfig

Enable systemd Xen services:

 # systemctl enable xen-qemu-dom0-disk-backend.service
 # systemctl enable xen-init-dom0.service
 # systemctl enable xenconsoled.service
 # systemctl enable xenstored.service
 # systemctl enable xendomains.service

Note that in case of error for enabling xendomains service, remove /etc/init.d/xendomains.

Update grub
Finally, update grub and reboot:

 # udate-grub
 # reboot

Example: Creating a Windows HVM (Hardware Virtualized) Guest

In order to create a Windows HVM (Hardware Virtualized) Guest, performs the following operations:

  • Setup the LVM storage: LVM, Logical Volume Manager, allows Linux to manage block devices in a more abstract manner. LVM creates logical volumes within a volume group that can share the same physical storage, known as physical volume.
  • Setup Linux Bridge in order to attach guest machines to the external network
  • Install Windows OS on the Xen HVM Guest
  • Run Windows OS on the Xen HVM Guest

Setup LVM storage

The LVM setup process can be summarized as allocating a physical volume, creating a volume group on top of this, then creating logical volumes to store data.

Install LVM:

  apt-get install lvm2

Create a physical volume associated with the device (e.g., /dev/XenVolumeGroup):

  pvcreate /dev/XenVolumeGroup

Create a volume group called vg0 using this physical volume:

  vgcreate vg0 /dev/XenVolumeGroup

Create a new logical volume, named windows, of 50Gbytes size on the volume group called vg0:

  lvcreate -n windows -L 50G vg0

Setup Linux Bridge for guest networking

In order to allow network access to the Xen guests, the Linux bridge package allows to create a virtual switch within Dom0. The switch will take packets from the virtual machines and forward them on to the physical network.

In order to install the Linux bridge package and its core component, launche the following command:

  % sudo apt-get install bridge-utils

Edit '/etc/network/interfaces' file by adding:

  1. dhcp
 auto xenbr0
 iface xenbr0 inet dhcp
    bridge_ports <your-network-interface>
  1. static bridging
 auto xenbr0
 iface xenbr0 inet static
   bridge_ports <your-network-interface>
   address <add>
   netmask 255.255.255.0
   gateway <gw>
   broadcast <bcast address>

Then, restart networking:

  % sudo service networking restart

Showing bridge setup:

  % brctl show
   bridge name     bridge id               STP enabled     interfaces
   xenbr0		8000.006065444af1	no      <your-network-interface>

Install Windows OS on the Xen HVM Guest

By assuming the Windows iso is located in /root/windows.iso, it follows an example of configuration file, referred to as windows.cfg to enable the installation of Windows on the logical volume.

 name="win"
 builder="hvm"
 
 memory=4096
 vcpus=2 #2cpus
 
 #disk option
 disk=['file:/dev/XenVolumeGroup/windows,hda,w', 'file://root/windows.iso,hdb:cdrom,r']
 boot="dc"
 
 #networking
 vif=['type=ioemu, bridge=xenbr0']
 
 #vnc or sdl
 vnc=1
 sdl=0
 
 stdvga=0
 usb=1
 usbdevice="tablet"
 ide0="noprobe"
 serial="pty"
 
 on_poweroff="destroy"
 on_reboot="preserve"
 on_crash="preserve"

Launch the following command to start the guest:

 $ xl create windows.cfg

Then, the VNC display should be available on port 5900 of your dom0 IP, for instance using vncviewer:

  $ vncviewer <dom0-ip-address>:5900

Then, proceed with Windows' installation. Once you have installed Windows by formatting the disk and by following the prompts the domain will restart. However, in order to prevent the booting from DVD, destroy the domain:

  $ xl destroy win

Run Windows OS on the Xen HVM Guest

After installing the Windows on the logical volume, change the boot line in the config file (i.e., windows.cfg)

  boot="c"

Then start the domain:

  $ xl create windows.cfg

and reconnect with VNC to have access to the Windows GUI.