How can a LVM thin volume be saved to a sparse file and then restored as a thin volume without making it "thick" ?

shodan

Active Member
Sep 1, 2022
218
61
33
I am searching for a filesystem agnostic method of taking any thin LVM volume, turning it into a file, copying that file to another system and then restoring a still-sparse LVM thin volume

Here are some suggestion I have found but not tried

Code:
rsync --sparse --progress /dev/pve/vm-600-disk-0 /root/vm-600-sparse.img
rsync --sparse /root/vm-600-sparse.img /dev/pve/vm-600-disk-0

dd if=/dev/pve/vm-600-disk-0 bs=1M status=progress | cp --sparse=always /dev/stdin /root/vm-600-sparse.img
cp --sparse=always /root/vm-600-sparse.img /dev/pve/vm-600-disk-0

qemu-img convert -O raw -p /dev/pve/vm-600-disk-0 /root/vm-600-sparse.img
dd if=/root/vm-600-sparse.img of=/dev/pve/vm-600-disk-0 bs=1M status=progress

I don't know if any of these would work or if there's another, better way to do this ?
 
I think you're trying to do this a too low-level. Why not make a backup of the VM with native proxmox tools, and restore it?

Barring that, you could backup in-vm to somewhere, recreate the thin disk / volume on another host, and in-vm restore...
 
  • Like
Reactions: leesteken