Since I installed Proxmox for my small home server, I struggled a bit with nas shares due to user ownership and permissions, but after searching a bit I encountered a tutorial (I can remember where) to do it easily. So, before I forget it I will write here how I nailed it.

It works to share a mountpoint from Proxmox to the LXCs, so if you have an ssd/hdd in that directory, it will share the whole disk.

It works by the following assumption:

  1. Proxmox maps group 110000 in Proxmox to group 10000 in the LXC.
  2. Proxmox maps user 101000 in Proxmox to user 1000 in the LXC.

On Proxmox

Create a nas user that will be shared across proxmox and the LXCs.

1
2
groupadd -g 110000 nas_shares
useradd nas -u 101000 -g 110000 -m -s /bin/bash

Mount the ssd/hdd

Make sure you already have the ssd/hdd formated, so mount it:

1
mount /dev/sda2 /nas~

Replace /dev/sda2 with the partition you will mount and share with the LXCs.

Change ownership of the mountpoint to the nas user.

1
chown -R nas:nas_shares /nas

On the LXCs

On each LXC you want to create a nas share, create the nas_shares group and the nas user that will be mapped to Proxmox.

From inside the LXC, run:

1
2
3
groupadd -g 10000 nas_shares
useradd nas -u 1000 -g 10000 -m -s /bin/bash
smbpasswd -a nas # add password for samba

Stop the container and from inside Proxmox, run this to map the mountpoint to the lxc:

1
pct set *lxc-number* -mp0 /nas,mp=/nas

Replace lxc-number whith the number of each lxc you want to share the mountpoint.

Restart the LXC and the mount point will be already available to use. Follow usual samba configuration from inside the LXC.

If you found this content useful, please support me:
BTC: 1E2YjL6ysiPxRF4AEdXChpzpesRuyzgE1y