LVM and convertion to vhd

Spiros Pap

Well-Known Member
Aug 1, 2017
87
1
48
44
Hi all,

I would like to convert an LVM based disk to VHD format.
I have done it successfully by getting a backup (vma.lzo) and then decompressing it, extracting it and converting it (qemu-img convert).

I woud like to do this in fewer steps. So, I have the following questions:
- I though of converting directly from the LV by doing:
# qemu-img convert /dev/mapper/vol1-vm--533--disk--0 -O vpc -o subformat=dynamic vm523.vhd

but when the VM is stopped, I can't find the corresponding LV in /dev/mapper. When the VM is started, the /dev/mapper device appears but I can't use it because it is active.
How can I solve this problem?

- Assuming that I am converting from a backup file (vma.lzo), how is it possible to do something like:
# lzop -d -c BACKUPFILE | vma extract -v - OUTPUTDIR | qemu-img convert ......some options...

I understand that OUTPUTDIR is a dir and qemu-img can't really use it, but I might be missing some other utils that can do it, in one step.

Cheers,
Sp
 
While I have not investigated the correct method for doing it from the command line, I have converted lvm stored vms by moving the drive to another medium in the web interface.

Select the VM in question
Select hardware.
Select the drive in question.
Above you will see "Move Disk" become available. Click it.
Select a target storage that will allow an image file.
Select an image type of your choice.
Run the conversion

After performing this you will find an image file in the location you selected. This can be converted via the tools you have already found (if needed).

Edited to add: Updated the instructions to actually run the conversion. Also qm move_drive seems like the equivalent from the command line.

Hope this helps
 
but when the VM is stopped, I can't find the corresponding LV in /dev/mapper. When the VM is started, the /dev/mapper device appears but I can't use it because it is active.
How can I solve this problem?
when stopping a VM the LV gets deactivated (needed when running a shared LVM on top of e.g. iSCSI)
you can activate it by running:
* `lvchange -aly vol1/vm-533-disk-0` (or more generally `lvchange -aly <VGname>/<LVname>`

I hope this helps!
 
# qemu-img convert /dev/pve/vm--533--disk--0 -O vpc -o subformat=dynamic vm523.vhd
 

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!