fstab-generator: support for x-systemd.onfailure (#42440)

1. test-fstab-generator: fix inverted /mnt symlink guard

   The test-18-options.fstab.input scenario was guarded by a check
   that was always true on a normal system, so it was silently
   skipped and its fixtures had drifted out of sync with actual
   generator output. This commit fixes the guard and repairs the
   stale fixtures it exposed.

2. fstab-generator: support for x-systemd.onfailure

   Add support for the x-systemd.onfailure= fstab option in
   systemd-fstab-generator. This allows configuring OnFailure=
   dependencies for generated mount units directly through /etc/fstab.

   For example:
/dev/sda1 /data ext4 defaults,x-systemd.onfailure=emergency.target 0 2

   results in the generated mount unit containing:
   [Unit]
   OnFailure=emergency.target

   This makes it possible to attach recovery targets or services to
   mount failures directly from fstab configuration.

   Add documentation and generator tests.
This commit is contained in:
Yu Watanabe
2026-09-23 09:08:24 +09:00
committed by GitHub
22 changed files with 107 additions and 17 deletions
+19
View File
@@ -284,6 +284,25 @@
<xi:include href="version-info.xml" xpointer="v220"/></listitem>
</varlistentry>
<varlistentry>
<term><option>x-systemd.onfailure=</option></term>
<listitem><para>In the created mount unit, configures an
<varname>OnFailure=</varname> dependency. The argument is a unit name, see
<option>x-systemd.requires=</option> above. This option may be specified more than
once. See <varname>OnFailure=</varname> in
<citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
for details.</para>
<para>Note that this option always applies to the created mount
unit only, regardless of whether <option>x-systemd.automount</option>
has been specified.</para>
<para>Note that this option is silently ignored on swap entries.</para>
<xi:include href="version-info.xml" xpointer="v262"/></listitem>
</varlistentry>
<varlistentry>
<term><option>x-systemd.graceful-option=</option></term>