Mounting VM lvm-thin image in lxc

GeorgiL

New Member
Jan 18, 2019
14
0
1
37
Greetings!

I'm trying to mount VM's disk image in LXC. Disk of interest is listed as following with fdisk -l

Code:
Disk /dev/mapper/pve-vm--100--disk--0: 200 GiB, 214748364800 bytes, 419430400 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 65536 bytes / 65536 bytes
Disklabel type: dos
Disk identifier: 0x00073ccd

Device                                 Boot    Start       End   Sectors   Size Id Type
/dev/mapper/pve-vm--100--disk--0-part1 *        2048   1026047   1024000   500M 83 Linux
/dev/mapper/pve-vm--100--disk--0-part2       1026048  11382783  10356736     5G 82 Linux swap / Solaris
/dev/mapper/pve-vm--100--disk--0-part3      11382784 419430399 408047616 194.6G 83 Linux

More precisely part3 which is going to be btrfs.
 
Hi,

Last but not least, you can also mount local devices directly, or mount local directories using bind mounts. That way you can access local storage inside containers with zero overhead. Such bind mounts also provide an easy way to share data between different containers
-- https://pve.proxmox.com/pve-docs/chapter-pct.html#pct_container_storage

you could add it by doing something like:
Code:
pct set VMID --mp0 '/dev/mapper/pve-vm--100--disk--0-part3,mp=/mnt/MP-IN-CT,backup=0'

This thread, which also has some infos if you really need to bass through a blockdevice, not just mount it, could be interesting too: https://forum.proxmox.com/threads/container-with-physical-disk.42280/
 
I will look into that. I wonder if it is going to work - after all that same partition is technically been used by the VM and the LXC simultaneously? It is expected for the LXC to do just reads but not guaranteed and VM is focused on writes.
 
That won't work, you need something which manages the shared access, else you just run into data corruption if you have them in both and they run both.
There are file systems made for this, like GFS2, or you export it in one of both as NFS/CIFS or there like and use it in the other with that protocol, where you're then save.
 
What if I mount that partition as loop device and read-only, within Proxmox and then bind mount that in LXC? PMS within the LXC doesn't need write access to that data, it just need to be able to see and read the multimedia from it. I did some testing with that but it seems, once partition is mounted like that in Proxmox, content of it is never refreshed again which is a problem as well.

EDIT: Currently I have it working with NFS share and it gets the job done, but I'm trying to replace it with something that is able to make the data available to the LXC without actually transfering data over the network since my performance tests proved NFS to generally use 3x more bandwidth, twice more IO delay and slightly more CPU usage when streaming video while transcoding it for the client over just have something like transcoding the video while PMS is in docker container within the same VM instead - thats like double virtualization but it still performed slightly better overall.
 
Last edited:

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!