If a file exists in the upper layer then there is no way to access a file
with the same name in the lower layer. If necessary, a combination of
loopback and union mounts can be made which will still allow the lower
files to be accessed by a different pathname.
How do I do this? I can't find a reference for file system loopback other than mounting .ISO and other block images which is clearly not the right meaning, and nullfs which just mentions the term in passing (but no concrete information).
My guess as to what's involved:
I think it might involve first mounting the "lower" layer (possibly twice, to 2 different mountpoints?), then mounting a unionfs over that mountpoint (or over one of the two mountpoints) to a second mountpoint. The idea being that the same file system is exposed unmodified through the first mountpoint and also exposed as a lower layer of a union via the second mountpoint. This is based off a hint at this web-page.
Update, clarifying the aim in response to @arrowd:
The man page says one can access the lower files (implied: the entire set of lower files) via loopback, and that this can makes the lower layer accessible in parallel both (A) as a lower layer of the unionfs, and (B) via a different "loopback" mount-point/pathname as a file system in its own right. I understand the concept of a loopback layer so this makes sense, and the
man page says it's doable, but I can't find the commands that will let me do it.
Being more specific, I want to overlay a file system in the usual way as a unionfs, but I also want a separate mountpoint to expose the lower layer by itself, to allow some tasks to read/write/search the entire "lower" file system directly as well, without being obscured/masked/overlaid by the union "overlay fs". So it isn't just about a single file - I need the entire "lower" layer also accessible via loopback and a separate mountpoint, not just accessible through the unionfs layer or on a file-by-file basis. It probably means I need to mount it twice in some way or another, first via loopback and then via unionfs, at the point where I initially set up/mount the unionfs layer, but I don't know how to do it.
The aim is that some cron tasks (and occasionally I as well) will need to update the files within the lower layer (without unmounting/disturbing the unionfs overlay), and not not just copy and update them within the "upper" layer as would happen with simple use of unionfs. So I need to have two mountpoints in use - one exposing the lower layer overlaid with a unionfs, and the other exposing the lower layer only without the unionfs overlay, and be able to use both in parallel in different tasks.
Also see comment I added above - I think it might involve mounting the lower file system twice (once directly, once as union), or mounting it once and remounting from that mountpoint a second time (as union). But I'm not sure and also unclear how safe it is.
Hopefully this is more clear as to the aim of the question.