Move disk stored on LVM from virtual machine to container?

Colin 't Hart

Well-Known Member
Jan 20, 2017
44
4
48
51
Frösön, Sweden
www.hiawathaavenue.com
Hi,
Upgrading some of our virtual machines, I'm moving to containers where possible. One of our machines has a large 4TB disk stored on LVM storage (we use hardware RAID underneath so we don't use ZFS).
I'd like to detach this disk from the virtual machine and attach it to the new container. is this possible? I'd rather not have to copy everything as I don't have the space to do that -- I'd have to temporarily reuse one of our hot-spares for that.
 
I dont think that is possible because VMs use block devices and LXCs file systems.
 
There are different types of storage that can be passed to container - directories or block devices.

Generally when a block device is passed there are hooks that format this device with a file system of your choice. That way the application running in Container can use the storage right away. Of course, one can pass a raw device and then if its a full OS (centos, ubuntu, etc) you can just exec into the container and format it manually.

I know there is some work being done in PVE to be able to move the disk between VMs. I am not sure if it was complete/committed yet. And, I dont know if that includes ability to move from VM to Container. The principal is the same, but perhaps the applicability is smaller.

Its certainly possible to move the disk manually, but its error prone. You will have to manually rename the LVM volume and edit the container configuration. Here is an example of a Container that uses external (Blockbridge) storage, which are iSCSI luns attached to a specific container:

more /etc/pve/nodes/pve/lxc/100.conf arch: amd64 cores: 1 hostname: 200 memory: 512 mp0: blockbridge-shared-storage:vm-100-disk-2,mp=/data,backup=1,size=8G net0: name=eth0,bridge=vmbr0,firewall=1,hwaddr=FA:BB:A9:70:D6:26,type=veth ostype: centos rootfs: blockbridge-shared-storage:vm-100-disk-1,size=8G swap: 512 unprivileged: 1

LVM config would be similiar - the mp0: line is the key. Make sure you detach the disk fully from VM first.


Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
 
  • Like
Reactions: Colin 't Hart

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!