Moving lvm raw storage from container/lxc to vm/qemu

valankar

New Member
Aug 10, 2023
6
2
3
I have an LXC container with a mountpoint defined in /etc/pve/lxc/101.conf:

Code:
mp0: local-lvm:vm-101-disk-0,mp=/mnt/storage,mountoptions=noatime,size=1500G

In my /etc/pve/storage.cfg, I have:

Code:
lvmthin: local-lvm
        thinpool data
        vgname pve
        content rootdir,images

Is it possible to move this storage to a VM/QEMU harddisk? The idea is I want to replace the LXC with a VM, so need to move the storage.

I'm assuming this is not possible with the UI, as I can detach it from the LXC but not sure how to attach it on the VM. I found this:

https://pve.proxmox.com/wiki/Moving_disk_image_from_one_KVM_machine_to_another

But it seems to be specific to moving storage between VMs, not LXC to VM.

Thanks!
 
I have an LXC container with a mountpoint defined in /etc/pve/lxc/101.conf:

Code:
mp0: local-lvm:vm-101-disk-0,mp=/mnt/storage,mountoptions=noatime,size=1500G

In my /etc/pve/storage.cfg, I have:

Code:
lvmthin: local-lvm
        thinpool data
        vgname pve
        content rootdir,images

Is it possible to move this storage to a VM/QEMU harddisk? The idea is I want to replace the LXC with a VM, so need to move the storage.

I'm assuming this is not possible with the UI, as I can detach it from the LXC but not sure how to attach it on the VM. I found this:

https://pve.proxmox.com/wiki/Moving_disk_image_from_one_KVM_machine_to_another

But it seems to be specific to moving storage between VMs, not LXC to VM.

Thanks!
Hey, not sure if this can be achieved on lvmthin type, on my case i managed to get this going with directory type storage and not lvmthin.

I am referring to PVE 7.4 version here:
So in summary you have the templates for lxc and VMs in /etc/pve/lxc/[lxcid].conf and /etc/pve/qemu-server/[vmid].conf.
On LXC conf file you will have usually mp0,1,etc full path for storage on VM you have usually scsi0,1,etc full path for storage.
On LXC the file type .raw format for storage while the VM has .qcow2 format.
In order to move storage from LXC to VM you need to convert .raw to .qcow2

Full guide here : https://docs.openstack.org/image-guide/convert-images.html

In short you need to do this :

qemu-img convert -f raw -O qcow2 image.img image.qcow2

Once that is done you need to move this new file to the correct path on your storage
Edit your template for VM file (/etc/pve/qemu-server/[vmid].conf) with new storage, you need to add manually same size as initial storage.
After you start the VM you need to mount the new storage and you should have same files as initial one.

PS: You will have an old type of FS and not LVM, if you want it as LVM that is different story.

Always backup all your data before you start playing with this as if you mess-up something along the way you will end up loosing all your data!

This is a "dirty" way in solving this up but it worked for me and I hope this will help you also !

GL!
 

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!