Copy disk from a lvm storage

eglyn

Member
Aug 26, 2021
26
2
8
44
Hi all,

I need to copy a VM disk which is setup on a LVM storage.

When I launch lvs, I see the disk like this:


Code:
vm-116-disk-0     vg-1 -wi-ao----  100.00g


But how extract the disk to a qcow2 or vmdk format to import it in another hypervisor ? (the new hypervisor does not have any access to the storage of the old hypervisor and is not a LVM Storage)

Thx :)
 
Last edited:
In the webinterface, click on the vm you want to export. under hardware you will see where the disk is located and what format it has. In a terminal, move to that directory and make a backup of your disk cp <your_disk_name> <backup_name>. Then you can use qemu-img to convert the image with qemu-img convert -f <format_your_disk_is_in> -O <format_you_want> <current_disk> <new_disk>. This, for you, will probably be something like qemu-img convert -f raw -O qcow2 disk.raw new_disk.qcow2.

For more info on qemu-img, check the manpages :)

Hope This helps
 
Thx, but I don't have any directory, the datastore is a vg group, and the hard drive of the VM is a LVM.
with a fdisk -l, it looks like this:

Code:
Disk /dev/mapper/vg--1--vm--116--disk--0: 100 GiB, 107374182400 bytes, 209715200 sectors
/dev/mapper/vg--1--vm--116--disk--0-part1 *         2048 207714303 207712256   99G 83 Linux
/dev/mapper/vg--1-vm--116--disk--0-part2      207716350 209713151   1996802  975M  5 Extended
/dev/mapper/vg--1-vm--116--disk--0-part5      207716352 209713151   1996800  975M 82 Linux swap / Solaris
 
Code:
pvesm path <storage>:vm-116-disk-0
qemu-img convert -O qcow2 <path-to-disk> <destination>
should do the trick
 
It does not works:

Code:
pvesm path STORAGE:vm-130-disk-0
/dev/vg-STORAGE/vm-130-disk-0

Code:
qemu-img convert -O qcow2 /dev/vg-STORAGE/vm-130-disk-0 /nas05_temp/copy_hdd/
Could not open '/dev/vg-STORAGE/vm-130-disk-0': No such file or directory

It seems the disk does not "exist" if the VM is shutdown oO

VM shutdown:
ls /dev/vg-STORAGE/
1672408959981.png

VM Start:
1672409000594.png

The 130 disk come back, but cannot make a qcow2, because in use -_-

And disks are just symbolic links to this:

1672409262666.png

And same, if I shutdown the VM, the dm-32 (from vm-130) disappears...
 
Last edited:
I read up on this a little more: you will have to move the disk to a non-lvm storage first. You can do this 1 of 2 ways:
  1. make a full clone of the vm: in the web interface click on the vm you want to clone and in the top-right of the page click `More` and then clone. Select the storage you want to clone to and which file format you want (qcow2 or vmdk in your case)
  2. move the disk to an non-lvm storage: click on the vm in the web interface, then on hardware->select the hard disk->click on disk Action->move storage. select the storage you want and the file format (qcow2 or vmdk)
Then all you need to do is find where the disk image is with pvesm path and move it where you need it
 

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!