How to clone a KVM (Windows) Virtual Machine?

Giovanni

Active Member
Apr 1, 2009
81
3
28
Hi

is it possible to clone an existing KVM (with Windows), to another one on the same server with a different name?

Lets say VM1 exists already, I want to clone VM1 and name it VM2. I assume I can create a blank VM2 shut it down and copy the virtual disk file into the VM2 and when I boot it it should bootup right? ( I just need to know the location then for the KVM VMs)

Thanks
 

tom

Proxmox Staff Member
Staff member
Aug 29, 2006
15,144
768
163
Hi

is it possible to clone an existing KVM (with Windows), to another one on the same server with a different name?

Lets say VM1 exists already, I want to clone VM1 and name it VM2. I assume I can create a blank VM2 shut it down and copy the virtual disk file into the VM2 and when I boot it it should bootup right? ( I just need to know the location then for the KVM VMs)

Thanks

yes, no problem, you got it.

things to consider:

  • never start a VM with identical MAC´s
  • location of files:
    the vm disks are here: /var/lib/vz/images/VMID/..
    the config files for the VM are here: /etc/qemu-server/
  • take care about OS internals (e.g. hostnames, SSH, keys, etc.). on windows, think of running sysprep or similar tool before cloning.
 

mikhmv

Guest
>>>never start a VM with identical MAC´s
It is really doesn't matter. I was have to create several VMs with same MAC (License issue). Guest is Windows XP. I just manually setup IP in each machine. and all of them work well and have access to internet
 

tom

Proxmox Staff Member
Staff member
Aug 29, 2006
15,144
768
163
VMs with identical MAC's are expected to cause serious network problems (packet loss). I dont know why it works for you.

I assume the windows boxes cannot communicate with each other.
 

mikhmv

Guest
Windows boxes communicate between together by MPI (c#) without package losses.
Each boxes have 2 NIC. One for license check (software try to check license server only from first NIC and license Mac dependent). Second for MPI communications.
they have different IP ranges: 192.168.10.XX and 192.168.4.XX with mask 255.255.255.0. No DNS server intered for first NIC.
Second NIC's have different MACs.
 

Petrus4

Member
Feb 18, 2009
249
0
16
yes, no problem, you got it.

things to consider:

  • never start a VM with identical MAC´s
  • location of files:
    the vm disks are here: /var/lib/vz/images/VMID/..
    the config files for the VM are here: /etc/qemu-server/
  • take care about OS internals (e.g. hostnames, SSH, keys, etc.). on windows, think of running sysprep or similar tool before cloning.

How about taking a vzdump backup and restoring it into a different vmid, will this work also?
 

yobbo75

Guest
Hey guys,

I know this was a while ago, however anyone searching for this may find it handy. I am a Linux newb, and with the help of google I was able to copy the hdd file as suggested above. I found this a bit cumbersome, and have found a better way, although it does require a few different programs. Here is what I did to clone, bear in mind this is assuming you have knowledge on how to use proxmox and Acronis. It doesnt take long to learn:

1. Download (what ever method you desire) - Acronis True Image / Magic ISO / NewSID (for xp only or syspre for win 7) (google all of them)
2. Create an ISO boot disk through Acronis (it is a start menu option)
3. In Proxmox, install your windows VM (via CD) and change as needed ready for cloning
4. In proxmox, Upload the ISO Image of the Acronis Boot Disk. In your Windows VM settings in proxmox select the ISO image as your CD drive
5. Start your windows VM (Pres F12 for boot options - and select the CD drive)
6. THis should book you into Acronis
7. Backup the disk to a FTP location (setup an FTP site in IIS on a local win 7 to Server 2008 or whatever ftp server you like)
8. Now, using Magic Iso, edit the acronis ISO image you made earlier and drag and drop the Acronis TIB file into it and save, this will alter the ISO
9. In Proxmox, uploade the new ISO image (delete the first one, or rename this one)
10. Create a new image, booting off the new ISO image you made. Restore the Image via Acronis (be sure to close the original VM down before restarting)
11. Once restroed restart the VM and bang, you have a clone. ]
12. Run NewSID or Sysprep to get different SID's and change the computer name and IP Addresses

These are a few more steps however if you plan on cloning a lot of vms for different purposes this is the best way i have found. Once you have uploaded your new ISO its just a simple matter of booting a newly configured vm off that into acronis, restore the image and restart, run the NewSid or Sysprep and re configured a couple of settings.

Its easier than doing a new installation everytime.

I hope this helps some one. Its nice to contribute!

Cheer
Ashman
 

tom

Proxmox Staff Member
Staff member
Aug 29, 2006
15,144
768
163
use clonezilla, no need for commercial software tools.
 

mikhmv

Guest
Simpler way:

Use OpenNebula:
1. Create images and make them Public
2. Create template
3. Make as many instances as you wish.....

I switch to OpenNebula from Proxmox only because cloning VMs in Proxmox so complicative.
 

tom

Proxmox Staff Member
Staff member
Aug 29, 2006
15,144
768
163
With Proxmox VE:

  1. Create the image/VM
  2. Make a backup
  3. Create as many instances as you wish with qmrestore

Example:
Create 10 new VM´s based on a backup, starting with VMID 10, ussing unique MAC addresses:

Code:
qmrestore --storage local  --repeat 10 --unique vzdump-qemu-150-2011_12_04-15_53_02.tar 200
 

Sotohiro Terashima

Guest
Hi all,
I tried 2 case of Backup Restore operation.
First: normal case
===========================
root@prox2:/mnt/pve/NFS/dump# qmrestore -storage local vzdump-qemu-100-2011_12_06-14_01_26.tgz 201
extracting archive '/mnt/pve/NFS/dump/vzdump-qemu-100-2011_12_06-14_01_26.tgz'
extracting 'qemu-server.conf' from archive
extracting 'vm-disk-ide0.qcow2' from archive
Formatting '/var/lib/vz/images/201/vm-201-disk-1.qcow2', fmt=qcow2 size=32768 encryption=off cluster_size=65536
new volume ID is 'local:201/vm-201-disk-1.qcow2'
restore data to '/var/lib/vz/images/201/vm-201-disk-1.qcow2' (2006581248 bytes)
tar: write error
2175+77624 records in
7654+1 records out
2006581248 bytes (2.0 GB) copied, 28.4474 s, 70.5 MB/s
=========================
This time I got success.
But got error message "tar: write error".

Second: with repeat option
=========================
root@prox2:/mnt/pve/NFS/dump# qmrestore -storage local -repeat 3 -unique vzdump-qemu-100-2011_12_06-14_01_26.tgz 210
Unknown option: repeat
400 unable to parse option
qmrestore <archive> <vmid> [OPTIONS]

=========================
This time,I got failure:"Unknown option: repeat"
Why?
And more,what is "tar: write error" ?
 

Sotohiro Terashima

Guest
Is Function of Qmrestore in 2.0 degraded than 1.9?
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get your own in 60 seconds.

Buy now!