[systemd-devel] Running a service *just* before unmounting filesystems

Hans de Goede hdegoede at redhat.com
Mon Jun 11 10:48:59 UTC 2018


Hi All,

So as you may have heard, I'm working on hiding the grub-menu
by default on single OS Fedora Workstation.  Part of the plan
here is to detect if a previous boot was successful and
cleanly shutdown the machine and show the menu (not hide the
menu) if the previous boot has failed to set either the
boot_success or shutdown_success flags:

https://fedoraproject.org/wiki/Changes/HiddenGrubMenu

So now I'm working on writing a unit file which will
be added to poweroff.target.wants, reboot.target.want,
etc. and which will call:

grub2-editenv - set shutdown_success=1

*just* before unmounting file systems, so clearly this
needs a:

Before: umount.target

That will guarantee that grub2-editenv can write to /boot,
but if I'm not mistaken then this will cause
my grub-shutdown.service to run as soon as
"systemctl poweroff" is called.

One solution to this would be to add a:

After shutdown.target

So we get

After: shutdown.target
Before: umount.target

According to:
https://www.freedesktop.org/software/systemd/man/bootup.html

shutdown, and umount run in parallel, now in practice
almost all services will have a Requires sysinit.target
which requires localfs.target, which requires all the
local mounts, so umounting won't happen until all the
services are stopped.

Still me adding a unit with a:

After: shutdown.target
Before: umount.target

Implicitly serializes this, which goes against:
https://www.freedesktop.org/software/systemd/man/bootup.html

So I'm not sure that that is a good idea.

For now I will continue working on this using just:

Before: umount.target

But I'm curious if using:

After: shutdown.target
Before: umount.target

Would be ok and/or if there are other suggestions for
doing this.

Regards,

Hans




More information about the systemd-devel mailing list