Right way to recursively share a path (like a symlink) and proper way to unmount/remount without messing with other mount points
1
vote
0
answers
132
views
Bind mounts seem to be hard. I am looking for the right way to use a bind mount to mount a given directory to another one pretty much like a symlink (but I can't use a symlink because my application is linux containers). I want to be able to unmount that directory without disrupting other possible mounts.
**Background**: I want to share a ZFS pool from a host system to a Linux container (proxmox). As a ZFS pool, there are many nested datasets and hence I would like to recursively do the mount. Also, some of the datasets are encrypted and should be transparently available if encryption keys are loaded and not, if unmounted.
**What I have tried**
1. Starting point is the host system with the
mountpoint
property set so that all datasets are mounted to /zpseagate8tb
on the host system. I can freely mount/umount datasets and load/unload encryption keys. I would like to clone this tree exactly into a container
2. I created another directory /zpseagate8tb_bind
, to which I bind mount the original pool. The intention is to mark it as slave to facilitate unmounting. I have the following line in my /etc/fstab
:
/zpseagate8tb /zpseagate8tb_bind none rbind,make-rslave,nofail
3. Then I use LXC's builtin capabilities to bind mount that directory into the container. The config file includes:
lxc.mount.entry: /zpseagate8tb_bind zpseagate8tb none rbind,create=dir 0 0
This works flawlessly until I want to unmount and/or the pool disappears (due to mistakenly unplugging) in which case there is always something unexpected happening. For example, /zpseagate8tb_bind
is empty while the data is still accessible/mounted inside the container. In nearly all cases I have to reboot everything to get a consistent state again.
What is the right approach to create this bind mount and which commands are needed to remove the mount from the container while not disturbing something else?
Asked by divB
(218 rep)
Nov 5, 2024, 05:42 AM
Last activity: Nov 5, 2024, 06:11 AM
Last activity: Nov 5, 2024, 06:11 AM