Sharing lvm-hosted directories between containers?

mp583

New Member
Aug 30, 2024
2
0
1
Hi, apologies if this is a repated post. I've spent a lot of time searching here and reddit and have really struggled to understand how to fix this problem.

I have two containers (plex and qbittorrent), I want to be able to download files via torrents and have plex be able to access them. The containers were set up using the proxmox helper scripts.

I've unfortunately got my proxmox host set up in a way that means my local directory is a small (32 gb) SSD and then I have an LVM set up which is a 1 TB NVME drive. I have it set up so that all of the VMs use this lvm ('vmdata') for their storage.

I have tried creating a directory on the host and mounting that to the containers, this works however the directory is created in the local 32 gb SSD which obviously has limited storage.

How can I create storage that can be accessed by my two containers and is hosted on my 1 TB NVME drive?

Any help appreciated, thank you!
 

Attachments

  • Screenshot 2025-07-25 141457.png
    Screenshot 2025-07-25 141457.png
    285.7 KB · Views: 0
I've thankfully had some help with this and have been able to fix it!

Here's the way to do it for anyone else interested:


Create a new Logical Volume named 'shared' in the existing volume group 'vmdata' with a size of 100GB:
sudo lvcreate -L 100G -n shared vmdata

Accept 'y' to this warning:
WARNING: ext4 signature detected on /dev/vmdata/shared at offset 1080. Wipe it? [y/n]:

Format the Volume
sudo mkfs.ext4 /dev/vmdata/shared

Create a new Mount Point
sudo mkdir -p /var/lib/vz/shared

Mount it
sudo mount /dev/vmdata/shared /var/lib/vz/shared

Make the Mount Persistent
sudo nano /etc/fstab
add the following line to the bottom of the file:
/dev/vmdata/shared /var/lib/vz/shared ext4 defaults 0 2
Apply the changes to fstab
sudo mount -a

Confirm it's mounted
df -h | grep /var/lib/vz/shared

Set permissions
sudo chmod 777 /var/lib/vz/shared

Bind Mount Into Containers...
Edit each container’s config file (change '106' for the correct container id):
sudo nano /etc/pve/lxc/106.conf
Add this line:
mp0: /var/lib/vz/shared,mp=/mnt/shared

Note: mp=/mnt/shared: mount point inside container