Sharing host folder with multiple containers

ymyinfinity

New Member
Oct 30, 2024
3
0
1
Hi all,

I have a host folder (Linux raid5) that I am able to successfully share with one container by editing the config, e.g.:

for 100.conf:
mp0 /mnt/nas,mp=/mnt/nas

When logged into the console for the above container, I am able to view contents
When I try to mount the same folder onto additional identical containers, the mount point within those containers is empty.

1. Is this expected behavior?
2. Is there an alternative solution that is recommended within the Proxmox community?

My use case includes a simple samba nas, separate emby server, and a torrent box, all writing/reading/editing the same set of subfolders

thank you all in advance!
 
Hi,
I had the same problem.
Edit: This solution is only valid for containers (LXC), not for virtual machines (VM).

Assume the /mnt/nas host folder refers to partition /dev/sda1.

If you want to share the partition /dev/sda1 with various containers you have to launch the following command from the host terminal (in this example container "101"):
Code:
sudo pct set 101 -mp0 /dev/sda1,mp=/mnt/nas

I hope this was helpful.
P.
 
Last edited:
  • Like
Reactions: waltar
Thank you SO much!
I was passing in the mounted folder from host into my container, which worked for the first container but would not for subsequent ones.
Passing in the partition itself worked flawlessly. I was about to resort to sharing a samba folder across the containers and hoping the internal virtual bridge would give me fast speeds, but your rec. was exactly what I was hoping for as a solution!!!!!!!
 
The question remain what happen in reality with that type of definition as a filesystem can just mounted once. If you mount a device to multiple os a filesystem will go corrupt as each of them don't know of another one.
 
  • Like
Reactions: Johannes S
The question remain what happen in reality with that type of definition as a filesystem can just mounted once. If you mount a device to multiple os a filesystem will go corrupt as each of them don't know of another one.
Interesting question.

Someone says that sharing host partitions to containers is not a problem (except when multiple containers write to the same file).
For host partition sharing to virtual machines, however, it is certainly safer to use NFS / CIFS or follow the guide "passthrough physical disk to virtual machine (VM)"

Have a nice day.
P.
 
Last edited: