XCP / Xenserver

From Unix Wiki
Jump to: navigation, search

Live Migration of HVM guest without XenTools


This might be only possible solution to move VM between different pools.


Networking and console might not work after migration. You would need to restart VM.

How to

One can trick XenServer to think that tools are installed by running following commands on XenServer with running VM:

vmname=<name of virtual machine>
domid=$(xe vm-list name-label=$vmname params=dom-id | cut -d':' -f2 | tr -d ' ')
xenstore-write /local/domain/$domid/attr/PVAddons/MajorVersion "6"
xenstore-write /local/domain/$domid/attr/PVAddons/MinorVersion "2"
xenstore-write /local/domain/$domid/attr/PVAddons/MicroVersion "0"
xenstore-write /local/domain/$domid/attr/PVAddons/BuildVersion "54078"
xenstore-write /local/domain/$domid/attr/PVAddons/Installed "1"
xenstore-write /local/domain/$domid/data/updated "1"


Software RAID 1


Next Instruction is applicable for XCP 1.6 and Xenserver 6.

Action plan

Backup GPT:

gdisk /dev/sda

Press: "b" gpt.sda ; Press: "q"

Load gpt from backup:

gdisk /dev/sdb

Press: "r" "l" gpt.sda "m"

Generate new GUID for /dev/sdb ; Press: "x" "g" "R" "w"

gdisk /dev/sdb

Set all partiotions to Linux RAID: Press: "t" "1" "fd00" "t" "2" "fd00" "t" "3" "fd00"

Create raid arrays:

mdadm --create /dev/md0 --level=1 --raid-devices=2 missing /dev/sdb1
mdadm --create /dev/md1 --level=1 --raid-devices=2 missing /dev/sdb2
mdadm --create /dev/md2 --level=1 --raid-devices=2 missing /dev/sdb3

Create bitmaps for each RAID device. Bitmaps slightly impact throughput but significantly reduce the rebuilt time when the array fails.

mdadm --grow /dev/md0 -b internal
mdadm --grow /dev/md1 -b internal
mdadm --grow /dev/md2 -b internal

Move volume group to new device:

pvcreate /dev/md2
vgextend VG_<TAB> /dev/md2
pvmove /dev/sda3 /dev/md2
vgreduce VG_<TAB> /dev/sda3
pvremove /dev/sda3

Copy OS to new raid device:

mkfs.ext3 /dev/md0
mount /dev/md0 /mnt
rsync -avP --stats --exclude=/mnt/* --exclude=/dev/pts/* --exclude=/sys/* --exclude=/proc/* / /mnt/

Make new raid device bootable:

mount --bind /dev /mnt/dev
mount -t sysfs none /mnt/sys
mount -t proc none /mnt/proc
chroot /mnt /sbin/extlinux --install /boot
dd if=/mnt/usr/share/syslinux/gptmbr.bin of=/dev/sdb

Cnange fstab and extlinux.conf configurations:

sed -i -e "s|root=LABEL=.*ro|root=/dev/md0 ro|g" /mnt/boot/extlinux.conf
sed -i -e "s|LABEL=.*/|/dev/md0    /|g" /mnt/etc/fstab
chroot /mnt

Regenerate new bootable image:

mkinitrd -v -f --fstab=/etc/fstab --theme=/usr/share/splash --without-multipath /boot/initrd-`uname -r`.img `uname -r`
umount /mnt/*
umount /mnt



Boot from second drive

sgdisk --typecode=1:fd00 /dev/sda
sgdisk --typecode=2:fd00 /dev/sda
sgdisk --typecode=3:fd00 /dev/sda

Add missing devices to raid and watch sync process:

mdadm -a /dev/md0 /dev/sda1
watch -n 1 cat /proc/mdstat
mdadm -a /dev/md1 /dev/sda2
watch -n 1 cat /proc/mdstat
mdadm -a /dev/md2 /dev/sda3
watch -n 1 cat /proc/mdstat


Missing IP for Management interface


One of the weirdest problems that may occur is that IP address is missing after reboot XEN host. Emergency network reset helps only for next boot and after another reboot network again not working.



'Device "xenbr0" does not exist. '




An unknown error occurred while attempting to configure an interface.


Problem caused by corrupted '/var/xapi/state.db'. To fix it you most probably need to recreate this file.

First of all make backup:

cp /var/xapi/state.db /var/xapi/state.db.back

Using xsconsole stop all running VM's and create backup of VM's meta-data to local SR. WARNING: network interfaces configuration may lost. Backup network interface configuration manually for all VM's.


Stop xapi service:

service xapi stop

Remove corrupted base:

rm -f /var/xapi/state.db

Start xapi service:

service xapi start

Start Emergency Network Reset via xsconsole. Server will reboot.

Check network configuration again. Reboot server a few times to ensure that network configuration works as expected.

Restore local SR if needed:

Restore VM's configuration via xsconsole.