How Can We Help?
Add Samba mount to Proxmox Container
Do you have some data that you have stored on a NAS and do you want to share it with a Proxmox container? This article will explain how to add a Samba share to your Proxmox Container.
Prerequisites
For this article, we assume that you already have a NAS configured with Samba. Additionally, we also assume that you have a Proxmox server setup with a Debian container.
Setup
When adding a Samba share normally you would edit the /etc/fstab
file and it would work. However, this does not work for Proxmox containers unless it is unprivileged. Since making a container unprivileged adds security risks I wanted to find another solution. The found solution is to add the mount to the Proxmox host and then share it as a mount point to the container.
Configure Proxmox Container
First, we have to add a group to the container which will be mapped later to the host. Do this by running:
groupadd -g 10000 lxc_shares
Now add your user to the newly created group by running:
usermod -aG lxc_shares root
Now make sure that the folder you want to mount to later exists (i.e. mkdir -p /mnt/media
). For the next steps on the Proxmox host, this container must be shut down!
Configure Proxmox Host
On the host create the folder for your mount (i.e. mkdir -p /mnt/lxc_shares/media
). Now edit the /etc/fstab
file and add the following line (make sure to tweak it to your needs!):
# Mount CIFS share on demand for use in LXCs
//__NAS_IP__/__SHARE__/ /mnt/lxc_shares/media cifs _netdev,x-systemd.automount,noatime,uid=100000,gid=110000,dir_mode=0770,file_mode=0770,user=__USERNAME__,pass=__PASSWORD__ 0 0
Now inform the system that you changed the file using systemctl daemon-reload
. Mount the share by running mount /mnt/lxc_shares/media
or mount -a to mount all the drives. Now add a mount point
to your preferred Proxmox container by editing /etc/pve/lxc/__LXC_ID__.conf
:
mp0: /mnt/lxc_shares/media/,mp=/mnt/media,ro=1
Make sure to validate that you do not overwrite other mount points and remove ro=1
if you want more permissions than read-only. More information about the parameters can be found at pve.proxmox.com. Now start your Proxmox container and validate if the mount is successful.
8 Responses
Your blog is a impressive resource for anyone seeking to discover more about these subjects.
Your website provides a wealth of information on these subjects. Thank you for sharing your wisdom with your readers.
Your blog is a great resource for anyone interested in learning about a variety of subjects. Thanks for all that you do.
Your writing captures the essence of the topic in a compelling way.
I really like the way you articulate things; it’s transparent and succinct.
Your enthusiasm for the subject is evident in your writing.
Your storytelling engages my attention from start to finish. I can’t resist read every single word you write.
Your enthusiasm shines through every paragraph, serving as a inspiring reminder of the impact that authentic dedication can have.