0

I know my title is a little bit convoluted so let me explain what I'm doing here in more detail. I am using a ephemeral root setup on my machine, essentially meaning that my / mount is a tmpfs and files which I wish to actually use and preserve across roots must be linked up in some way onto this / mount. For the most part, I already have a trivially working solution which bind mounts different files from a persistent device onto /sysroot in the initrd, which are then preserved in the actual system and can be used like normal.

A small problem I have with this approach is because the mount occurs within the initrd, I do not have much practical control on the systemd dependencies for the generated mount unit. I cannot declare a mount unit in initrd because it's attributes will not be preserved after switch_root, and I can't declare another mount unit for my bind mount because then it'll remount over itself twice (admittedly I do not know if this is a problem but it doesn't seem "good").

My main concern is that I want to declare some special ordering for these bind mounts so they aren't killed too early by systemd upon system shutdown (when reaching umount.target). The main reason for this is because I persist /var/log as a bind mount to preserve journalctl logs, and when umount.target tries to unmount the bind mount at this location it fails. I want to somehow remove the ConflictsWith=umount.target that is attached to all generic mount units so that there isn't a requirement to unmount so early. Ideally I'd not perform a unmount at all and simply allow the exitrd to smoothly kill the mount alongside the /, which is automatically does.

I'm not particularly sure how I can really do this though, especially given the fact that mounts occuring in initrd do not really preserve any systemd-specific information that I can use. These mounts are also dynamically generated through configuration so hard-coding them into /etc/fstab with options like x-systemd.some-opt is not feasible.

So far the only thing I've tried was creating a .mount unit in the system, which as mentioned prior, would "remount" the mount unit over top, leading to two reported founds and thus requiring two unmount operations on the same mount location. Again, no idea if this is an actual problem, but it doesn't seem particularly clean which does bother me. This remount would occur even if I would specify Options=remount,..., which is admittedly a bit confusing but not something I could really understand either way.

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.