OpenNebula Import VM as sparse

 

Identify the VM disks

name = "pladm"
[...]
vif = [ 'bridge=vbr61,mac=zzz' ]
disk = [ 
   'phy:/dev/vgxen_raid10/pladm_root,xvda,w',
   'phy:/dev/vgxen_raid10/pladm_data0,xvdb,w',
   'phy:/dev/vgxen_raid10/pladm_data1,xvdc,w',
   ]
serial='pty'

 

Shut down the vm

xl shutdown pladm

 

Mount /var/lib/one to /mnt/one

 

and use the uploads directory to supply the vm image:

xyz:/xen/configs# for vbd in /dev/vgxen_raid10/pladm_* ; do
   dd if=$vbd bs=1024k | 
   cp --sparse=always /proc/self/fd/0 /mnt/one/upload/$( basename $vbd) 
done

 

Including cp with --sparse=always enforces sparsifying the image, which works better than dd conv=sparse. Apparently :-)

 

The following blog entry is where I learned about using cp as sparsifier:

http://blog.f1linux.com/2013/05/02/howto-backup-a-running-vm-to-sparse-file-and-restore-using-lvm-snapshots-dd-and-cp/

  • No labels