LVM and convertion to vhd

Spiros Papageorgiou

Active Member
Aug 1, 2017
77
0
26
42
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
 

Denny

Active Member
Jul 28, 2016
86
20
28
58
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
 

Stoiko Ivanov

Proxmox Staff Member
Staff member
May 2, 2018
7,749
1,276
169
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!
 

hadrich

Active Member
Dec 9, 2011
7
0
26
# 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 your own in 60 seconds.

Buy now!