IntroductionI'm currently trying to get rid of Citrix XenServer implementation in favour of plain Xen. I've got a couple of reasons for that, but most importantly it's about control and about avoiding downtime.
These are four frustrating examples out of many more. Don't get me wrong, XenServer works brilliantly as long as you don't need to do uncommon tasks. Wait, is NIC replacement uncommon really? Never mind Citrix has made some effort to complicate things (and formats), but thanks to this article Get me out of here!So let's get our images off of XenServer back onto the plain Xen environment. Aforementioned URL quotes a xenmigrate.py script, which isn't linked anywhere (or I'm just blind), but with the description of the file format, we can get started using plain bash anyway... Once you've exported your VM (or its snapshot, or a template) to an .xva file, copy it onto your Xen box. To summarize the .xva format:
What I'm intending to do is to write a bash script, which does exactly that:
In bash it looks like this: #!/bin/bash dd if=/dev/zero of=blank bs=1024 count=1k test -f image.img && rm -f image.img touch image.img max=`ls ???????? | sort | tail -n1` for i in `seq 0 $max`; do fn=`printf "%08d" $i` echo -n "$fn of $max" if [ -f "$fn" ]; then echo " - appending chunk" cat $fn >> image.img else echo " - filling blank" cat blank >> image.img fi done rm -f blank echo "Done." It's really simple and not (yet) extracting lvm volumes etc. It's merely to give you an idea of how to easily get your data back to Xen. You can refine yourself, I'm sure. To use it, simply extract the backup.xva (or whatever you called it), and go into the resulting directory Ref:x. Then you run the script: tar xf backup.xva cd Ref:x /path/to/convert.sh Get a coffee. This may take a moment. In the end you'll have image.img, ready to be used as a disk in Xen. Your relevant configuration file would look like: bootloader="/usr/bin/pygrub" extra = "text console=xvc0" name = "imported" memory = "256" disk = [ 'tap:aio:/root/image.img,xvda,w' ] vif = [ 'bridge=xenbr0' ] vcpus=1 Your instinct probably tells you to run something along the lines of mount -o loop ... in order to check the image first. You need to use parted to find the offsets, for example:
# parted image.img
GNU Parted 1.8.1
Using /root/Ref:6/image.img
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) unit
Unit? [compact]? B
(parted) print
Model: (file)
Disk /root/Ref:6/image.img: 10737418239B
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
1 32256B 106928639B 106896384B primary ext3 boot
2 106928640B 10733990399B 10627061760B primary lvm
So in this case the offset is 32256B. You'd mount it as follows: mount -o loop,offset=32256B image.img /mnt Mount it read-only (or better unmount it altogether) before starting a Xen domain from it. Otherwise you're likely to cause mess there. ConclusionI'm not taking side against Citrix here at all. For many people/companies it's simply great and straight-forward. However, while we're still running some XenServer clusters and will be running them for a while, I intend to migrate back to plain Xen over time. That's because of all those little nuisances and limitations, which are caused solely by XenServer's toolstack, not actually by Xen. If you came to read this article for the same reasons, you now know how to get started and can take it from there. Far less complicated than it seemed. |
Shortcuts |