Container not mounting /etc/fstab on boot

sweaty-tim

New Member
Feb 3, 2023
3
0
1
I am in the process of moving my containers from native LXC on Debian 11 to Proxmox and thus learning Proxmox in the process.

I have setup a Debian 11 container using 'pct' to mount a remote file system (SSHFS) using /etc/fstab. It mounts when I execute 'mount -a' without issue from inside the running container.

Is there something special I need to enable for Proxmox to execute /etc/fstab on boot?
 
Hi, I was able to have an sshfs mounted at boot inside a Debian 11 LXC with the following fstab entry:
Code:
user@HOST:PATH /mnt/sshshare fuse.sshfs defaults,reconnect 0 0
Can you post your /etc/fstab?
 
I'm having the exact same issue as OP. Works with 'mount -a', but doesn't work automatically after a reboot.
My container is Debian 10 (Turnkey), trying to connect to a VM of OMV6 on the same node.

/etc/fstab
docker@172.16.11.22:/srv/mergerfs/snapraid/conf /mnt/config fuse.sshfs noauto,x-systemd.automount,_netdev,user,idmap=user,follow_symlinks,identityfile=/home/docker/.ssh/id_rsa,allow_other,default_permissions,ServerAliveInterval=15,ServerAliveCountMax=3,uid=1001,gid=101,reconnect 0 0 docker@172.16.11.22:/srv/mergerfs/snapraid/data /mnt/media fuse.sshfs noauto,x-systemd.automount,_netdev,user,idmap=user,follow_symlinks,identityfile=/home/docker/.ssh/id_rsa,allow_other,default_permissions,ServerAliveInterval=15,ServerAliveCountMax=3,uid=1001,gid=101,reconnect 0 0

I've been struggling with this for weeks, so this config has kept growing. user,idmap=user,follow_symlinks,uid=1001,gid=101
May not be needed, but various tutorials used them. ServerAliveInterval=15,ServerAliveCountMax=3 were added to try and avoid the connection from closing. But if I understand the purpose of x-systemd.automount correctly, I shouldn't need them?
 
Can you try removing the x-systemd.automount option, and replacing noauto with auto? Apparently systemd.automount doesn't work inside a LXC because autofs is not namespace-aware (some more info here). However, at least in my Debian 11 LXC, systemd does mount the sshfs at boot without the x-systemd.automount option.
 
  • Like
Reactions: dvdwsn
The mount is working well so far. I haven't had any issues doing backups either which older posts said can cause the system to hang. One small issue is that the permissions set by newly created folders aren't how I'd like them. When created automatically it's set to rwxr-sr-x, but I would like rwsrwsr-x.
Any way I change this?
 
I would guess that noauto,x-systemd.automount is a combination that works on ordinary systems (because it delegates the task to systemd.automount [1]). But since systemd.automount doesn't work within containers, we have to remove x-systemd.automount from the options, and use auto instead.
Does not work here. E.g., /dev/zvol/rpool/data/myZVOL /mnt/zvol xfs auto,rw,noatime does not mount here on reboot. mount -a works.
 
Does not work here. E.g., /dev/zvol/rpool/data/myZVOL /mnt/zvol xfs auto,rw,noatime does not mount here on reboot. mount -a works.
How is that relevant to the original Question ?

You cannot have ZFS Module working in an LXC Container, at least not in an unprivileged one. Not sure if your Remark is applicable to a privileged LXC Container or if you had a KVM Virtual Machine.

For an unprivileged Container the Solution mentioned by @fweber seems to work for me, although to be fair even with x-systemd.automount, NOT all Containers had this Issue.

My Use-Case was to bind-mount a Host Directory (/zdata/MyFolder) into the Guest (data/MyFolder - yes you need to omit the initial /, this gets mounted inside the Guest to /data/MyFolder in Practice :) ):
Code:
lxc.mount.entry: /dev/net dev/net none bind,create=dir
lxc.mount.entry: /zdata/MyFolder data/MyFolder none rbind,create=dir,optional 0 0
lxc.cgroup.devices.allow: c 10:200 rwm
lxc.cgroup2.devices.allow: c 10:200 rwm
lxc.idmap: u 0 100000 165536
lxc.idmap: g 0 100000 165536

Then the Host Permissions need to be Offset by the UID Inside the Guest PLUS 100000.

So if your User inside the Guest is 2000, you need to run a chown -R 102000:102000 /zdata/MyFolder and inside the Guest that will show as owned by 2000:2000 User :).