Create a VM copy from a VM snapshot

Chris&Patte

Renowned Member
Sep 3, 2013
58
1
73
Hello,
i use Proxmox on ZFS.
I have a VM with multiple snapshots. I would now create a copy of that VM based on a dedicated snapshot of that VM.
Is that possible? With "zfs send | ssh zfs revev " to another host?

How to do that?

Thanks a lot.
 
Right click on the source VM and hit clone. Then you pick the snapshot you want:

Screenshot 2023-05-19 at 14.20.15.png
 
a second problem is that i do not have enough free space on that host. That's the reason for the question about "zfs send".
I used "zfs send <zfs volume>" to copy VMs over network on a different host. But in that case all snapshots got transmitted over.
This would be also a solution, but i would copy much more data then needed and would need to revert to a snaphot and delete all unneeded snapshots on the target afterwards.
So my question is if can "zfs send" a dedicated snapshot only into a zf volume without snapshots?
 
OK, the solution is really simple. Even in the GUI it does not work, via "zfs send" it does. When target VM already exists as a copy of the source system, it's:

Code:
zfs send Storage10k/vm-100-disk-0@vorSAPDMZTest | zfs recv -F Storage10k/vm-101-disk-0

if target VM does not exist already, you had to manually create it or copy the vm.conf file to the new VM name.

And of course you can transmit that pipe data stream over the network to a different host as well.
 
hm, that worked in my test before, but now that it's gettinmg serious, it doesn't.
Even the target VM has no snapshot attached, it says it has one

Code:
cannot receive new filesystem stream: destination has snapshots (eg. Storage10k/vm-200-disk-2@--head--)
must destroy them to overwrite it

in the GUI of the target system it does NOT show any snapshot, but zfs tells me
Code:
Storage10k/vm-200-disk-2@--head--         5.04G      -      179G  -
 
I take a slightly different approach but I think it will result in something similar to what you're looking for.

I use LXCs instead of VMs, and this is so I can mount ZFS datasets on the host directly in the LXC. The result is that you get nearly native performance of the underlying storage. There are a few things you need to do manually, mainly create the zfs dataset and define the storage mount from the host command line.

ssh in to the host.
Bash:
zfs create /zpool_name/dataset_name

and edit your lxc config:
Bash:
vi /etc/pve/lxc/<id>.conf

and make it look something like this:
Bash:
arch: amd64
cores: 16
features: keyctl=1,nesting=1
hostname: hostname_here
memory: 32768
mp0: /mnt/zpool_name/dataset_name,mp=/mnt/data/dataset_name
net0: name=eth0,bridge=vmbr0,firewall=1,gw=ip.addr.goes.here,hwaddr=mac_addr,ip=cidr_group/24,tag=vlan,type=veth
ostype: ubuntu
rootfs: local-zfs:subvol-152-disk-0,size=32G
swap: 512
unprivileged: 1
lxc.apparmor.raw: mount,

Now you can't send that directly to another machine - the zfs mount causes an issue. but, if you remove mp0 temporarily, you can migrate to another machine, or clone if you want. Then use zfs send to copy the dataset, locally or to another machine. Then edit the LXC config and add the mount again.

Slightly annoying workflow but it results in great disk performance. Plus if you want, you can mount multiple storage devices to the same LXC.

The biggest drawback of this approach is that it can be difficult to edit kernel-level configs or share other hardware from the host, like a GPU, but all of that is still possible, just different than with a VM.