Transferring a disk from a machine to a container

tayra

Renowned Member
Sep 25, 2017
15
0
66
52
Hi!
I have a virtual machine with a large capacity disk. Required to connect this disk to the lxc container. I created a new disk in the container, then using lvm2-tools renamed the disk I needed, giving it the name of the one created in the container. When launched, the container gives an error that the container did not start. It is impossible to copy data between disks, there are several terabytes.. How can I connect a disk from another virtual machine to the lxc container?
 
How can I connect a disk from another virtual machine to the lxc container?

short answer: you cannot. Those technologies are fundamentally different in their disk layout.

long answer:
Depends on a lot of things, in general it should be possible:
- Often, people partition their non-boot-disks, so you probably need to expose the partitions via kpartx
- mount the partition directly in to the container from the PVE host, which is very easy with ZFS, but I haven't tried it with LVM, probably the same.
- copy/rsync the files
- unmount and remove partition bindings with kpartx.