You are not logged in.

#1 2013-07-18 15:29:49

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,810

Systemd: more nuanced automatic fs mounting

OOTB, local-fs.target will cause a drop to emergency mode if a filesystem [in fstab without noauto] can't be found, even if the problem fs is not necessary for the system to boot/function. I think this is highly ridiculous, so I came up with a way to make auto-mounting more nuanced. Anyway, below is an abridged account of my tinkering followed by my solution.

The first thing I tried was copying a mount file - we'll call it foo.mount - from /run/systemd/generator to /etc/systemd/system. I changed the line "Before=local-fs.target" to "Before=local-fs-opt.target". I also copied /usr/lib/s../s../local-fs.target to /etc/s../s../local-fs-opt.target and removed the "OnFailure" and "OnFailureIsolate" lines. I'm going to ignore the (now obvious) problem with this approach for the moment. Anyway, I rebooted and ran 'systemctl show foo.mount'. It was clear my static mount file was being used, but it was still "RequiredBy=local-fs.target". I assumed that was due to /run/s../g../local-fs.target.requires/ containing a reference to it, which I further assumed was caused by the fs being set to auto mount in fstab. So I changed the fstab entry to noauto.

Of course, I want it to be automounted. Now we're back to the obvious problem I alluded to earlier: the system has no reason to 'aim for' local-fs-opt.target. IOW it might as well not exist. So I found out what causes the system to 'aim for' local-fs.target, and concluded that was sysinit.target. So I copied /usr/lib/s../s../sysinit.target to /etc/s../s../ and added local-fs-opt.target to its "Wants" and "After" lines. I also created /etc/s../s../local-fs-opt.target.requires/ and created a symlink in it to /etc/s../s../foo.mount . It looks like things are working as planned. 'foo' is mounted when it's available, but if it's not the system continues to boot.

Obviously, a big problem is the amount of custom/static unit files, which will have to be checked for changes upon systemd updates. And of course there's a lot of manual intervention. Anyway, thoughts/criticism/tacos welcome. Thanks.


But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

#2 2013-07-18 15:36:30

65kid
Member
From: Germany
Registered: 2011-01-26
Posts: 663

Re: Systemd: more nuanced automatic fs mounting

... or you could just add "nofail" to the mount options...

Offline

#3 2013-07-18 15:40:40

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,810

Re: Systemd: more nuanced automatic fs mounting

Doh, I had never heard of that option. I kind of expected there to be an existing solution, but I didn't expect it to be that simple or I would have asked first.

:'( for my wasted time...

Last edited by alphaniner (2013-07-18 15:41:34)


But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

#4 2013-07-18 15:42:59

65kid
Member
From: Germany
Registered: 2011-01-26
Posts: 663

Re: Systemd: more nuanced automatic fs mounting

yeah, this should be documented in the systemd-fstab-generator man page, but currently isn't (it's on systemd's TODO list however).

Last edited by 65kid (2013-07-18 15:43:21)

Offline

#5 2013-07-18 17:33:32

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: Systemd: more nuanced automatic fs mounting

To me there do seem to be some valid reasons to use a native systemd mount unit rather than have it autogenerated by the systemd-fstab-generator.  But when you do that, you should comment the line in your fstab, because although the unit in /etc will take precedence, you will still have the unit potentially being pulled into a "WantedBy" situation like you noticed.

Offline

#6 2013-07-18 18:30:34

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,810

Re: Systemd: more nuanced automatic fs mounting

With default options, things are pulled into RequiredBy. Add nofail, and they're pulled into WantedBy. Add noauto, and they're not pulled in at all. At least that's what I saw.

Anyway, this was an interesting experience. Down with the haters; I love systemd.


But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

Board footer

Powered by FluxBB