I'm running Arch Linux and systemd.
/etc/fstab I have something like this:
LABEL=XYZ /mypath vfat noauto,[...]
/mypath/main /newplace none bind,noauto 0 0
I currently have to mount
/newplace with two commands:
I also have to
I need to simplify that to just one
I need to use the exact
mount (and related
umount) command shown immediately above because of an existing script. To clarify:
The single command
mount /newplace should first mount
/mypath, then mount
/mypath should remain mounted.
umount /newplace should first umount
/newplace and then also umount
I can change
/etc/fstab and some other details of my device. But I cannot change the script that calls
mount /newplace. I also cannot automount
/newplace because it needs to usually remain unmounted except when the script is run.
I have been reading about recursive bind mounts, shared, private, slave and other mount options, but I have not seen a way to achieve what I'm seeking.
Update: in response to comments, this is obviously not a recursive mount, so I called it a "prerequisite" mount. I hope the term is appropriate. I thought about the term "reverse recursive mount" but that seems very bad. I am taking "prerequisite" to mean something that must come before and that provides the continuing foundation for the requisite. Generally, the prerequisite cannot be forgotten or removed while continuing with the requisite.
In this case,
/mypath (prerequisite) and
/newplace (requisite) both remain mounted when
/newplace is mounted, and they would both be unmounted (probably in reverse order of course) when calling
The ideal solution will use either systemd, Python 3 or Xonsh. (A Bash script is also acceptable. I do not have zsh or other shells installed.)