Share disk between different containers

neur0mancer

New Member
Nov 23, 2023
19
1
3
Hey

I want to setup a little NAS for private use.

I created one container that runs as a "cloud mirror", it simply mirrors files from my onedrive account to one of the disks. The disk is mounted to /mnt/cloud/.

Now I want to add another container, that is responsible for Samba. How can this container now access the data from the disk mounted to the first container?

cheers
neur0
 
OK, it took me a while to undersand, for anyone else coming after me, withouth the experience:

1. Create a directoy in Datacenter's storage section (can someone explain the difference to the directoy section within disks within the nodes section?)
2. add the following mount config to all required container configurations files (in your node under /etc/pve/lxc/):

Code:
mp0: /mnt/bindmounts/shared,mp=/shared

While the first folder apparently points to the directory of your container and the MP param refers to the directoy you previously created

But this leaves me confused: The directoy created now is located on the physical disc my node is using. How can I assign it to any other disk?
 
Last edited:
To be more precise:
PVE is installed on Disk #1, which takes around 100 Gbyte, the rest is unsed.
Disk #2 is completlely unsued.

Disk #2 has been mounted to /mnt/pve/data2 so I can easily bind-mount it into any container.
So I'm going to datacenter/storage and adding LVM pointing to the volumge group PVE that contains Disk #1. Naming it data1

But now, as you can see, data1 is not mounted, so how do I bind-mount it to use it accross different containers?

1700918488459.png
 
OK, here is the solution, it's a more complicated than assumed, I don't know if this is the right way - but it works!

First I added a filesystem to my blank SSD, that's the easy part, via SSH:

Code:
mkfs.btrfs /dev/nvme1n1p1
mkdir /mnt/data2

adding this to etc/fstab

Code:
/dev/nvme1n1p1    /mnt/data2    btrfs    defaults    0    1

reloading fstab and mount

Code:
systemctl daemon-reload
mount /mnt/data2/

Checking the proxmox node in the Web UI now shows a filesystem and I am probably able to bind-mount it to my containers.

Now to the disk that my proxmox is running on. The installation already created a volume group (pve) and some logical volumes). I checked that using those commands:
Code:
vgdisplay
lgdisplay

(lsblk could lead to the same information, but the above commands are more specific).

What we see here is, that there's a couple of space left over. The WebUI does not offer a way to use that, at least I could not find out where. So I first created an additional logical volume for that volume group "pve":

Code:
lvcreate -n data1 --size 1000G pve

and again I created the file system and all that stuff from above...

et voila - at least I have the left-over space now available in /mnt/data1 and mnt/data2.


Now let's get to the sharing-thing.

Now create a fresh container, but deactivate the "unprivileged" feature.

After that I edited the config file for this container, again via shell:

Code:
nano /etc/pve/lxc/101.conf

added those lines:

Code:
mp0: /mnt/data1,mp=/mnt/data1
mp1: /mnt/data2,mp=/mnt/data1

And the ressources area already has been refreshed, nice:


1700925341602.png


And ls -la /mnt also gives me the folders.

Now lets double check if my use case is working, too: Creating a second container, same settings as above.

What does ls -la /mnt show? The content of my "shared disks"! Beautiful!

Let's do a quick check for this "unprivileged thing": Adding a container that is "unprivileged": Creating, Modifying, Running - and the folders are visible, but not writable!

Perfect! Took my like 6 hours to find that out. Lessons learned: The WebUI is a nice thing, but it is totally not helpful when managing your storage (not complaining, still love proxmox!). So its kind of mandatory to prepare the storage situation via SSH (or the built-in shell of the WebUI) and than spin up your containers.

Thanks for listening - over and out :D
 

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!