NOTICE: Xenmigrate does not currently support NFS stored VMs. This example is for Logical Volume stored VMs.
If you've used the migrate program to export to a raw file (don't confuse an "export" using the xenmigrate program with an "export" from Xen Center), you'll then need to use the import function of the program to turn that raw file into a logical volume that open source xen can then use as its disk. Here's a run through of an export and import on my system...
First we export from the source machine. Adjust the export and virtual name location accordingly. In my case, I mounted an NFS share under /mnt and have a virtual with a name-label of "nessus01":
[root@xen01 xentool]# python xenmigrate.py -x /mnt/nessus01 nessus01
xenmigrate 0.6.2 -- 2009.01.05
vm name-label : nessus01
vm uuid : 75177e74-92de-1efc-be47-d7047ad62b69
vm disk uuid : e236d60f-ad35-4887-ad0a-c187d8093a07
vm disk partid : xvda
vm disk uuid : dae12c56-6702-4e56-bb15-530aa43d1019
vm disk partid : xvdd
export dev : /dev/VG_XenStorage-8aa40725-3429-83d5-a560-e5c18dd19efe/LV-e236d60f-ad35-4887-ad0a-c187d8093a07
to raw file : /root/mnt/nessus01_xvda_8.00
Activating Volume:
Using logical volume(s) on command line
Activating logical volume "LV-e236d60f-ad35-4887-ad0a-c187d8093a07"
Found volume group "VG_XenStorage-8aa40725-3429-83d5-a560-e5c18dd19efe"
Creating VG_XenStorage--8aa40725--3429--83d5--a560--e5c18dd19efe-LV--e236d60f--ad35--4887--ad0a--c187d8093a07
Loading VG_XenStorage--8aa40725--3429--83d5--a560--e5c18dd19efe-LV--e236d60f--ad35--4887--ad0a--c187d8093a07 table
Resuming VG_XenStorage--8aa40725--3429--83d5--a560--e5c18dd19efe-LV--e236d60f--ad35--4887--ad0a--c187d8093a07 (252:18)
RW notification every: 1.0GB
Exporting: 1.0GBrw 2.0GBrw 3.0GBrw 4.0GBrw 5.0GBrw 6.0GBrw 7.0GBrw 8.0GBrw
Successful export
Deactivating Volume:
Using logical volume(s) on command line
Deactivating logical volume "LV-e236d60f-ad35-4887-ad0a-c187d8093a07"
Found volume group "VG_XenStorage-8aa40725-3429-83d5-a560-e5c18dd19efe"
Removing VG_XenStorage--8aa40725--3429--83d5--a560--e5c18dd19efe-LV--e236d60f--ad35--4887--ad0a--c187d8093a07 (252:18)
Found volume group "VG_XenStorage-8aa40725-3429-83d5-a560-e5c18dd19efe"
You many need to restart your VM:
xe vm-startup -u root uuid=75177e74-92de-1efc-be47-d7047ad62b69
Then we import on the destination open source xen machine. Change the mnt locaiton and the Volume Group accordingly. In my case I had a ./mnt mounted to my NFS share and a Volume Group named VolGroup00. You need to be using LVM storage on open source Xen (the recommended way) for this to work:
[root@xen04 xentool]# python xenmigrate.py -i mnt/nessus01_xvda_8.00 VolGroup00
xenmigrate 0.6.2 -- 2009.01.05
import raw file : mnt/nessus01_xvda_8.00
to lv : nessus01
in vg : VolGroup00
lv size : 8.00GB
xen config partid : xvda
Creating Logical Volume:
Setting logging type to disk
Finding volume group "VolGroup00"
Archiving volume group "VolGroup00" metadata (seqno 1511).
Creating logical volume nessus01
Creating volume group backup "/etc/lvm/backup/VolGroup00" (seqno 1512).
Found volume group "VolGroup00"
Creating VolGroup00-nessus01
Loading VolGroup00-nessus01 table
Resuming VolGroup00-nessus01 (253:18)
Clearing start of logical volume "nessus01"
Creating volume group backup "/etc/lvm/backup/VolGroup00" (seqno 1512).
RW notification every: 1.0GB
Importing: 1.0GBrw 2.0GBrw 3.0GBrw 4.0GBrw 5.0GBrw 6.0GBrw 7.0GBrw 8.0GBrw
Successful import
Then you need to add the appropriate information to your virtual's configuration file:
disk = ['phy:/dev/VolGroup00/nessus01,xvda,w']
root = '/dev/xvda1 ro'
| Images 0 | ||
|---|---|---|
| No images to display in the gallery. |
I installed Citrix Xen to create one virtual debian linux just for sandbox purposes. Now I'd like to move this virtual debian linux to Amazon E2C, so I think I should use your xenmigrate.py. I'm not so technical in linux and I don't know what to do after xenmigrate.py -x
I have the file but I cannot mount with "mount -o loop -t ext3 exportfile /newext3vm"
Could you help me?
Thanks
David edited 13:54, 28 Apr 2009
Traceback (most recent call last):
File "xenmigrate.py", line 453, in ?
lvpartid=importname.split('_')[-2]
pace
You should use the Amazon EC2 tools to create your bundle. The actual program is ec2-bundle-vol. You can find the docs for that specifically here: http://docs.amazonwebservices.com/AmazonEC2/dg/2006-10-01/CLTRG-ami-bundle-vol.html
pace
The format of the directory is ova.xm and hda/
hda/ contains chunk-000000##.gz.
each chunk is 1GB(1000000000) in size(pre gzip)
I had to hack xenmigrate to strip the chunk- and to use the filenames from the directory not a generated one.
I will soon find out how well this has all worked
I first used citrix xenconvert to convert the vhd file to xen virtual appliance format. This created an ova.xml and hda/ directory with chunk-000000##.gz files.
I then renamed all the chunk- files to not have chunk in front of them, and added an extra 0 at the beginning and then gunzipped them all.
Next I ran
python ./Xenmigrate.py -c ./hda/ new-server.img
which created a file called new-server.img
Finally i added this into a xen configuration file as
disk = [ 'file:/usr/xen/tfs_2010/tfs.img,ioemu:hda,w']
and started the virtual machine
I guess all the renaming and gunzipping of files could be done within the python script, but my python scripting abilities arent up to much so i did it a manual way
After scratching my head for some time (and almost going back to Citrix) I figured I'd just do it the old skool way:
Boot into Clonezilla on the VM in XenServer, grab the drive image, create a new VM on Xen with the right size drive, boot into Clonezilla and restore the drive.
Worked a charm for me, so it may be useful for others having trouble here (or others too thick to figure it out like me!).
python xenmigrate.py -convert=Ref\:7/ server.img
and all I get is:
"xenmigrate 0.7.2 -- 2010.01.01
(c)2010 Jolokia Networks and Mark Pace -- jolokianetworks.com
ERROR: convert source directory or file does not exist"
Any tips on what I should try?
scramatte: Assuming you end up with an image file you will then need to use that as a file source for either an LVM partition or as just a file source for your vm. You can use the xenmigrate script to load an image into an lvm (--import) or you and just use the file you created with xen 4.1. If you need more help, email me directly. My email address is my last name pace @ our domain name. edited 20:08, 13 Sep 2011
line 296
numfiles=len([dirobj for dirobj in os.listdir(refdir) if os.path.isfile(dirobj)])
only works if the workingdirectory is the ref directory itself. It should read:
numfiles=len([dirobj for dirobj in os.listdir(refdir) if os.path.isfile(os.path.normpath(refdir) + '/' + dirobj))])
That way it does not matter in what directory the script is started and should work in all environments
numfiles=len([dirobj for dirobj in os.listdir(refdir) if os.path.isfile(os.path.normpath(refdir + '/' + dirobj))])