[SOLVED] Bind mount to reflect Samba mount owner/permissions?

jonathanku

Renowned Member
Feb 16, 2012
14
0
66
I have a few containers running on Proxmox and have a challenge with a Bind mount vs a Samba share.

Container 101 has a directory shared via Samba (it's effectively my NAS). Anything written to it via Samba adopts file ownership & permissions determined by the samba process / config.

That same directory is also mounted via a bind mount (set up from the PVE host) by another container - container 102, because I can't get it to mount via CIFS / samba - but any files written via this bind mount have different ownership and permissions.

I thought about having a cron job to chown + chmod such files, but that seems very messy. Is there a good way to force files coming in via that bind mount to assume the desired ownership / permissions - i.e. same as how Samba files appear?
 
I've tried the following:

mount -o umask=755,gid=500,uid=500 --bind /var/lib/vz/private/101/var/NAS /var/lib/vz/root/106/m
nt/nas/

(following an example from here/Superuser.com)

The mount works, but the umask, gid and uid seem to have no effect. When in container 106, any new files are still created as root:root.

Edited to add: 500:500 is the NAS user - so any files written via samba to the directory have that ownership.
 
Found a solution... maybe it was obvious, but not to me initially...

In the container where I'm using this bind mount, I run as a new user with the same UID/GID as the NAS user from the NAS container -- i.e. 500:500. The files then get written with the same ownership as those writte
 

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!