LXC - Remount mountpoint without rebooting Container

silverstone

Renowned Member
Apr 28, 2018
204
30
68
36
I have a use-case where I have some Host Folders that is actually an NFS Mount (could also be CIFS/SSHFS/...).

I then bind-mount (bind or rbind) inside the LXC Container in the Form of
Code:
lxc.mount.entry: /mnt/<container_name> data/ none rbind,create=dir 0 0

I devised my own little Script (NOT specific to Proxmox VE, also used on general-purpose Debian/Ubuntu/Fedora/etc) to fix NFS/CIFS-Samba/FUSE Mountpoints that end up being stale (as well as their rbind/bind Descendants) using

https://github.com/luckylinux/fix-stale-handle

However, for Proxmox VE and LXC Containers, it doesn't really work, because even remounting the Host Mountpoint at /mnt/<container_name>
(and fixing the Issue from the Host point of View) doesn't actually fix the Issue in the LXC Container. The Share inside the LXC Container stays empty.

Neither does rebooting the LXC Container IIRC. I believe the only "Solution" that works is first stopping the LXC Container, wait a bit, then start the LXC Container again.

I tried some Things in this little Script here to analyse which are the LXC Mountpoints that might depend on NFS/CIFS/etc Shares, but no actual implementation yet:

https://github.com/luckylinux/fix-stale-handle/blob/main/list-pve-mounts.sh

Is there some "hidden" Command to force-remount or force-rescan of the Host Share and (re)mount it inside the LXC Container without having to first stop it then start it again ?
 
Last edited:
I use lxc.mount.entry: /dev/dvb dev/dvb none bind,create=dir 0 0, which sometimes disappears on host and gets recreated. A reboot of the container (afterwards) works fine.
Have you tried using a hookscript to make sure the host mount is done pre-start and umount done post-stop?

EDIT: I think it is normal Linux filesystem behavior that you end up with a unusable mountpoint when the underlying storage is unmounted, even when it is remounted. I cannot explain why your situation is different to mine. Glad to hear you found a work-around.
 
Last edited:
I use lxc.mount.entry: /dev/dvb dev/dvb none bind,create=dir 0 0, which sometimes disappears on host and gets recreated. A reboot of the container (afterwards) works fine.
A reboot of the LXC Container does NOT work for me.

I need to first stop the LXC Container. Wait a few seconds. Then start the LXC Container again.

Have you tried using a hookscript to make sure the host mount is done pre-start and umount done post-stop?
In a normal Situation, the Share is already mounted on the Host.

The only "Fix" I could find for the initial (after Host Boot) is:
Code:
pvenode config set --startall-onboot-delay 60

However, as I said, if an NFS Share gets stale and I trigger a remount using my own Script (mentioned in my first Post above), even though now it's fine on the Host Mountpoint, it still won't show up inside the Container :( .

It also seems unnecessary to have to reboot the Container when the share is already fixed host-wise. It's like the 2 are not really connected after LXC Container Boots, yet somehow the LXC Container has access :rolleyes: ? It's definitively NOT like a "normal" bind or rbind ...