qm clone gives unable to parse volume ID

jasminj

Active Member
Sep 27, 2014
44
0
26
Vienna 19
jasmin.anw.at
I tried to clone a vm with the command line, by
qm clone 101 103 -name WebServerNew -format raw -full 1
but got "unable to parse volume ID '/dev/disk/by-id/scsi-SATA_WDC_WD40EFRX-68_WD-WCC4EHJF6HLX-part1'"

This partition is a raw mapping into my virtual machine:
virtio7: /dev/disk/by-id/scsi-SATA_WDC_WD40EFRX-68_WD-WCC4EHJF6HLX-part1,backup=no

It seems the regular expression in /usr/share/perl5/PVE/Storage/Plugin.pm:185 does not support this.
a) Is this a bug?
b) If no, what is the preferred way to do such a raw mapping?

BR
Jasmin
 
We have basic support for using device names directly, but extended functionality like
clone is not implemented.
 
clone is mostly useful when you use linked clones, and you can only do that if you have knowledge of the underlying storage.
 
clone is mostly useful when you use linked clones, and you can only do that if you have knowledge of the underlying storage.
I have only one server with a local storage and I need this to make simple backup copies before I start to upgrade the running machine. Yes, I could write a shell script doing this, but I like the idea of Open Source and to contribute to a great project. In the long term, this feature needs to be implemented anyway, so why not doing it now and helping me to get my VM copy command ;)

After a little analysing it seems the support of "/dev/..." is implemented quite simple. In my opinion, it should have been done by adding a new media type to the disk properties, but this was maybe a factor of implementation time.

I decided to extend the clone command the same way, by checking the disk path. So the patch is quite simple and straight forward.

Please find attached a patch for the current available PVE 3.3 (I didn't use the git version).
I tested it with two virtual machines. Note, copying can't be initiated by the WEB Interface, when a device is used as disk. Use this command within a shell on your host:
Code:
qm clone <vmid> <newid> -name <new-name> -full 1
Look here for further details of the clone command.

BR
Jasmin
 

Attachments

  • pve_clone_device.diff.txt
    1.4 KB · Views: 15
The development team does currently not add this extension.

For those who need cloning VMs with local disk devices (like me), they need to patch the PVE code.
I re-based the patch for the latest qemu-server (3.3-1).

HowTo apply the patch (as root):
Download the attached file to /root
# cd /usr/share/perl5/PVE
# patch --dry-run -p2 < /root/0001-Make-qm-clone-working-with-devices_3.3-1.patch.txt
When patching will work without errors, execute the command without --dry-run.

If something gets wrong with the patch, reinstall the original package:
# apt-get install --reinstall qemu-server

Keep in mind that the clone will have real copies of any virtual disk, but the local disk device keeps shared!
Whether this really works depends on the used file system on the shared local disk device or how it is mounted within the second guest.

BR
Jasmin
 

Attachments

  • 0001-Make-qm-clone-working-with-devices_3.3-1.patch.txt
    1.8 KB · Views: 17
Last edited:

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 yours easily in our online shop.

Buy now!