mkdumprd: append "x-initrd.mount" to the mount options.

Now when mount in /etc/fstab fails, systemd would not consider it as
critical and it would continue to boot. In fact, emergency service is
triggered, but not in a isolation mode, and it results in the emergency
service getting shutdown at some point later of the boot process. We
need isolation otherwise we won't see any emergency service.

That is because in kdump initramfs, mount units specified in /etc/fstab
are required by "local-fs.target". When any of these mounts fails,
local-fs.target fails.

For kdump initramfs, we need to isolate to emergency service on any of
the mount failure, that said, every service should be stopped and onlu
emergency service would run. But local-fs.target won't trigger that on
its failure. That means in case of mount failure, local-fs.target also
enters failure state, but all the service will continue without any
interruption.

After digging looking into source code of systemd-fstab-generator. I
find "x-initrd.mount" using in initramfs mount, will make the mount
units required by "initrd-root-fs.target" rather than it's used to be
"local-fs.target".

"initrd-root-fs.target" is suitable to us because if it fails, it will
isolate to emergency service. That means in case of any mount failure,
the emergeny service will start and everything else will stop. We want
this effect because we need to take kdump fail-safe action when there's
a mount failure.

From systemd unit point of view, "initrd-root-fs.target" has
OnFailureIsolate=yes, but "local-fs.target" doesn't. From
systemd.unit(5):

OnFailureIsolate=
    Takes a boolean argument. If true, the unit listed in OnFailure=
    will be enqueued in isolation mode, i.e. all units that are not its
    dependency will be stopped. If this is set, only a single unit may
    be listed in OnFailure=. Defaults to false.

NOTE: Harald who contributed "x-initrd.mount" in systemd, confirmed that
      this feature will stay.

Signed-off-by: WANG Chao <chaowang@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
This commit is contained in:
WANG Chao 2014-06-16 16:57:21 +08:00
parent 0787accc4e
commit de95c74a76

View File

@ -106,6 +106,20 @@ to_mount() {
_fstype=$(findmnt -k -f -n -r -o FSTYPE $_dev)
_options=$(findmnt -k -f -n -r -o OPTIONS $_dev)
_options=${_options/#ro/rw} #mount fs target as rw in 2nd kernel
# "x-initrd.mount" mount failure will trigger isolate emergency service
# W/o this, systemd won't isolate, thus we won't get to emergency.
# This is not applicable to remote fs mount, because if we use
# "x-initrd.mount", remote mount will become required by
# "initrd-root-fs.target", instead of "remote-fs.target". That's how it is
# handled within systemd internal. We need remote mount to be required
# "remote-fs.target", because we need to bring up network before any remote
# mount and "remote-fs.target" can be a checkpoint of that.
# If remote mount fails, dracut-initqueue will still start and once
# dracut-initqueue finishes, kdump service will start. Because remote mount
# failed, kdump service will fail and it will lead to kdump error handler.
if ! is_nfs_dump_target; then
_options="$_options,x-initrd.mount"
fi
_mntopts="$_target $_fstype $_options"
#for non-nfs _dev converting to use udev persistent name
if [ -b "$_source" ]; then