How to use bindfs for mounting shared folders into CT?

mateusz1234

Member
Apr 22, 2021
12
0
6
32
I found that post about using bindfs for sharing files into CT https://forum.proxmox.com/threads/lxc-user-mappings.75450/
It seams like much easier thing that using mp0 and setting up uid/gid map (I couldn't get it done).
So I add into fstab on the host system:

Code:
/etc/pve/nodes/ocs /sas/subvol-101-disk-0/certs fuse.bindfs perms=0000:u+rD,uid-offset=100000,gid-offset=100000 0 0
/etc/pve/nodes/ocs /rpool/data/subvol-103-disk-0/certs fuse.bindfs perms=0000:u+rD,uid-offset=100000,gid-offset=100000 0 0

It mounts fine and maps fine, but the problem is that the files a visible in the CT only if that patch is mounted after the CT is started, if the CT is started when the patch is already mounted the dir is empty in the CT, when I then umount it on the host and remount it starts working.

I don't need high performance since I only need that for sharing proxmox certs with the CT because I have only on public IP and running different services on different ports (I know I could use a reverse proxy but I don't like that).
Can I somehow use lxc.mount.entry for binding the bindfs?
 
I tried already:
Code:
lxc.mount.entry: /etc/pve/nodes/ocs certs fuse.bindfs perms=0000:u+rD,uid-offset=100000,gid-offset=100000 0 0
But that just fails when the CT is started:
Code:
()
__safe_mount_beneath_at: 1106 Function not implemented - Failed to open 51(dev)
safe_mount: 1204 Invalid argument - Failed to mount "/etc/pve/nodes/ocs" onto "/usr/lib/x86_64-linux-gnu/lxc/rootfs/certs"
mount_entry: 1953 Invalid argument - Failed to mount "/etc/pve/nodes/ocs" on "/usr/lib/x86_64-linux-gnu/lxc/rootfs/certs"
lxc_setup: 3353 Failed to setup mount entries
do_start: 1218 Failed to setup container "103"
__sync_wait: 36 An error occurred in another process (expected sequence number 5)
__lxc_start: 1999 Failed to spawn container "103"
TASK ERROR: startup for container '103' failed
Could that be done with some hooks?
 
Hmm...
That worked:
1. In /etc/fstab on the host system
Code:
/etc/pve/nodes/ocs /certs fuse.bindfs perms=0000:u+rD,uid-offset=100000,gid-offset=100000 0 0
And then just:
Code:
pct set 103 -mp0 /certs,mp=/certs
And it works :D, looks like a hack but I am happy with that solution :).

BTW I am not sure how the mp0 in proxmox works but it seams like lxc has a "shift" option for adding disks: https://discuss.linuxcontainers.org/t/mount-home-directory-read-only-permission-denied/10241
Would be nice if proxmox supports that, would safe a lot of trouble when doing shared dirs.
 

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!