User Tools

Site Tools


xenvirtualmachines

This is an old revision of the document!


Xen Virtual Machines

<toc><ul><li><link topicref=“2”>Xen Server dom0</link></li><li><link topicref=“3”>Xen Client domU using debootstrap</link></li><li><link topicref=“4”>Xen Client domU using netboot</link></li></ul></toc>

Xen Server dom0

You should create a partition a bit larger than the amount of ram allocated to domU guests. If you shutdown the dom0, the domU guests are saved state to '/var/lib/xen/save'

lvcreate --size 4.1g --name xen vg01
mkdir /var/lib/xen

And add to /etc/fstab

/dev/mapper/vg01-xen /var/lib/xen            reiserfs noatime         0       2

and mount

mount /var/lib/xen

Xen Client domU using debootstrap

Below 'vm01' is the hostname of my VirtualMachine. The Xen host has 2 Raid 1 mirrors, so I want to stripe across them creating a Raid 10.

lvcreate --size 1g -i 2 --name vm01-slash vg01
lvcreate --size 2g -i 2 --name vm01-swap vg01
lvcreate --size 2g -i 2 --name vm01-usr vg01
lvcreate --size 2g -i 2 --name vm01-var vg01

mkfs.ext3 /dev/vg01/vm01-slash
mkswap /dev/vg01/vm01-swap
mkfs.reiserfs /dev/vg01/vm01-usr
mkfs.reiserfs /dev/vg01/vm01-var

mount /dev/vg01/vm01-slash /mnt/
mkdir /mnt/usr /mnt/var
mount /dev/vg01/vm01-usr /mnt/usr/
mount /dev/vg01/vm01-var /mnt/var/

debootstrap --arch amd64 --include=reiserfsprogs,linux-image-2.6-xen-amd64,ssh lenny /mnt

cd /mnt
cp /etc/hosts etc/
sed -i 's/xen01/vm01/g' etc/hosts
echo vm01 &gt; etc/hostname
cp /etc/apt/sources.list /etc/apt/preferences etc/apt/

<strong>etc/network/interfaces</strong>:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
        address 1.2.3.4
        netmask 255.255.255.0
        gateway 1.2.3.1

<strong>etc/fstab</strong>:

# /etc/fstab: static file system information.
#
# &lt;file system&gt; &lt;mount point&gt;   &lt;type&gt;  &lt;options&gt;       &lt;dump&gt;  &lt;pass&gt;
proc            /proc           proc    defaults        0       0
/dev/sda1        /               ext3    defaults,errors=remount-ro 0       1
/dev/sda3 /usr            reiserfs defaults        0       2
/dev/sda4 /var            reiserfs noatime        0       2
/dev/sda2 none            swap    sw              0       0
/dev/hda        /media/cdrom0   udf,iso9660 user,noauto     0       0

<strong>boot/grub/menu.lst</strong>:

title           Debian GNU/Linux, kernel 2.6.26-2-xen-amd64
root            (hd0,0)
kernel          /boot/vmlinuz-2.6.26-2-xen-amd64 root=/dev/sda1 xencons=tty ro
initrd          /boot/initrd.img-2.6.26-2-xen-amd64

title           Debian GNU/Linux, kernel 2.6.26-2-xen-amd64 (single-user mode)
root            (hd0,0)
kernel          /boot/vmlinuz-2.6.26-2-xen-amd64 root=/dev/sda1 xencons=tty ro single
initrd          /boot/initrd.img-2.6.26-2-xen-amd64

<strong>/etc/xen/vm01.cfg</strong>:

# Debian 5.0
memory = 1024
name = &quot;vm01&quot;
bootloader = &quot;/usr/lib/xen-3.2-1/bin/pygrub&quot;
disk = [ 'phy:vg01/vm01-slash,sda1,w', 'phy:vg01/vm01-swap,sda2,w', 'phy:vg01/vm01-usr,sda3,w', 'phy:vg01/vm01-var,sda4,w' ]
# Default bridged network interface
vif = [ 'bridge=xenbr0' ]
vcpus = 2
# Single-user mode
#extra = &quot;1&quot;
umount /mnt/usr /mnt/var /mnt
cd /etc/xen/auto
ln -s ../vm01.cfg .
xm create -c vm01.cfg

After boot you need to:

<list><ol><li>Set a root password, create local user accounts</li><li><strong>dpkg-reconfigure tzdata</strong></li><li><strong>dpkg-reconfigure exim4-config</strong></li></ol></list>

Xen Client domU using netboot

This creates the LV with equal-sized stripes over a 2 drive Volume Group (Creates a raid0 LV for write performance).

# lvcreate --size 10g -i 2 --name ubuntu14 vg01
  Using default stripesize 64.00 KiB
  Logical volume &quot;ubuntu14&quot; created
mkdir /var/lib/xen/trusty-netboot
cd /var/lib/xen/trusty-netboot
wget -c http://archive.ubuntu.com/ubuntu/dists/trusty/main/installer-amd64/current/images/netboot/xen/initrd.gz
wget -c http://archive.ubuntu.com/ubuntu/dists/trusty/main/installer-amd64/current/images/netboot/xen/vmlinuz

<strong>/etc/xen/ubuntu14.cfg</strong>:

name = &quot;ubuntu14&quot;

memory = 1024
vcpus = 4

disk = [ 'phy:vg01/ubuntu14,sda,w' ]
vif = [ 'bridge=xenbr0' ]

kernel = &quot;/var/lib/xen/trusty-netboot/vmlinuz&quot;
ramdisk = &quot;/var/lib/xen/trusty-netboot/initrd.gz&quot;
extra = &quot;debian-installer/exit/always_halt=true -- console=hvc0 url=...&quot;

Start the installer:

xm create -c ubuntu14.cfg

After the install, revise the cfg file to comment out the local kernel/ramdisk and add pygrub.

...
#kernel = &quot;/var/lib/xen/trusty-netboot/vmlinuz&quot;
#ramdisk = &quot;/var/lib/xen/trusty-netboot/initrd.gz&quot;
#extra = &quot;debian-installer/exit/always_halt=true -- console=hvc0 url=...&quot;
bootloader = &quot;pygrub&quot;
xenvirtualmachines.1195960993.txt.gz · Last modified: 2020/02/13 22:55 (external edit)

free spam filter