F
fellipebl
Guest
Hello users,
after a long search for a VM cloning solution and some unsuccessful tests with virt-clone we figured out a different way to clone VMs.
There are some steps to follow:
Regards,
Fellipe Lima (fellipebl@gmail.com)
Hrvoje Bosnjak (hrvoje.bosnjak@gmail.com)
after a long search for a VM cloning solution and some unsuccessful tests with virt-clone we figured out a different way to clone VMs.
There are some steps to follow:
- Take a look in this two directories: (i) /etc/qemu-server/(VM configuration file).conf and (ii) /var/lib/vz/images/(VM storage folder).
- Copy the script in /var/lib/vz/images/ and execute it with four parameters: sudo sh clone_vm.sh (source VM id) (destination VM id) (destination VM name) (MAC address for the VM).
Notice: the MAC address of all the VMs must be unique for avoid packet looses.
Here goes the shell script for do it:
Code:#!/bin/sh SOURCE_VM_ID=$1 DEST_VM_ID=$2 DEST_VM_NAME=$3 DEST_VM_MACADD=$4 # new vm physic file directory mkdir /var/lib/vz/images/$2 # new vm configuration file directory echo -e "name: $DEST_VM_NAME\nide2: local:iso/ubuntu-10.04-server-amd64.iso,media=cdrom\nvlan0: virtio=$DEST_VM_MACADD\nbootdisk: ide0\nostype: l26\nide0: local:$DEST_VM_ID/vm-$DEST_VM_ID-disk-1.vmdk\nmemory: 512\nonboot: 1\nsockets: 1\ncores: 1" >> /etc/qemu-server/$DEST_VM_ID.conf # clone the physic vm cp /var/lib/vz/images/$SOURCE_VM_ID/vm-$SOURCE_VM_ID-disk-1.vmdk /var/lib/vz/images/$DEST_VM_ID/vm-$DEST_VM_ID-disk-1.vmdk
- Verify the copy process by the web-interface.
- Finish and have fun.
Regards,
Fellipe Lima (fellipebl@gmail.com)
Hrvoje Bosnjak (hrvoje.bosnjak@gmail.com)