0

OpenSUSE Leap 15.6.

I have a systemd service which backups the system to a NFS share just before the latter is unmounted using rsnapshot:

[Install]
WantedBy=multi-user.target

[Service]
ExecStop=sh -c 'systemctl list-jobs | grep -q "poweroff.target.*start" && mountpoint -q /mnt/nas/backup && rsnapshot -V alpha'
RemainAfterExit=true
TimeoutStopSec=infinity

[Unit]
After=mnt-nas-backup.mount
Description=rsnapshot

The systemctl list-jobs | grep -q "poweroff.target.*start" && mountpoint -q /mnt/nas/backup shananigans are just guards set in place to make sure that the service won't run on reboot and that it will run only on poweroff, if the NFS share is accessible: you can ignore those. For any practical purpose, the ExecStop action is just running rsnapshot -V alpha.

I thought it would be nice for plymouth to display a relevant message such as "Backing up..." on the poweroff's splash screen while the ExecStop action is running.

Mind you, this is uncharted territory for me.

First I started plymouth on /dev/tty3 from the fully booted-up system, and I tried displaying a simple message by running:

sudo plymouthd --no-daemon --tty=/dev/tty3

In one terminal and:

sudo plymouth display-message --text="Test"

In another terminal.

This worked perfectly.

After that, I copied the backup service to /etc/systemd/system/test.service and edited it so that the thing would just display a message on plymouth's splash screen and wait, changing TimeoutStopSec to 60 as a safety measure:

[Install]
WantedBy=multi-user.target

[Service]
ExecStop=sh -c 'plymouth display-message --text="Test"; sleep 30'
RemainAfterExit=true
TimeoutStopSec=60

[Unit]
After=mnt-nas-backup.mount
Description=test

sudo systemctl enable --now test.service and sudo reboot.

Of course, the poweroff process hangs for 30 seconds with no message on plymouth's splash screen.

Although technically I should make sure plymouth-reboot.service is still up when the service runs, since I latched this using After=mnt-nas-backup.mount, plymouth-reboot.service being up is basically guaranteed, and proof of that is the fact that I can see the service running and hanging the poweroff process.

I thought maybe some kernel parameter was preventing plymouth from displaying messages.

So I changed:

GRUB_CMDLINE_LINUX_DEFAULT="splash=silent preempt=full mitigations=auto quiet security=apparmor"

to:

GRUB_CMDLINE_LINUX_DEFAULT="splash preempt=full mitigations=auto quiet security=apparmor"

and ran sudo grub2-mkconfig -o /boot/grub2/grub.cfg (basically changing splash=silent to splash).

quiet should be irrelevant here, however I also tried removing quiet at some point; security=apparmor also should be irrelevant since there are no apparmor profiles configured for plymouth.

No dice.

Any idea what could be preventing this from working?

Here's the contents of plymouth-reboot.service, which isn't shedding any light for me:

[Unit]
Description=Show Plymouth Reboot Screen
[email protected] display-manager.service plymouth-start.service
Before=systemd-reboot.service
DefaultDependencies=no
ConditionKernelCommandLine=!plymouth.enable=0
ConditionVirtualization=!container

[Service]
ExecStart=/usr/sbin/plymouthd --mode=reboot --attach-to-session
ExecStartPost=-/usr/bin/plymouth show-splash
Type=forking
RemainAfterExit=yes

1 Answer 1

0

The Plymouth message isn't displaying during shutdown in your OpenSUSE Leap 15.6 system is due to the timing of the service execution and the state of the Plymouth process during the shutdown sequence.

During the shutdown process, systemd begins stopping services and unmounting filesystems. By the time your custom service attempts to execute the plymouth display-message command, Plymouth may have already transitioned to a state where it no longer displays messages or its TTY is no longer active. This generally happens because of the following reasons:

Plymouth TTY might be deactivated for shutdown process: As part of the shutdown process, the TTY that Plymouth is using could be deactivated before your service runs.

Plymouth could be finishing its job: When the system is in the shutdown process, plymouth-reboot.service might have already completed its task, and Plymouth may not be accepting further commands to display messages.

In order to display the message from Plymouth, you need to run the service when Plymouth is fully active and able to display messages. The correct sequence for the service is to ensure that Plymouth message is displayed is:

[Unit]
After=mnt-nas-backup.mount plymouth-start.service
Before=shutdown.target

[Service]
ExecStop=/bin/sh -c 'systemctl list-jobs | grep -q "poweroff.target.*start" && mountpoint -q /mnt/nas/backup && plymouth display-message --text="Backing up..." && rsnapshot -V alpha'
RemainAfterExit=true
TimeoutStopSec=infinity

[Install]
WantedBy=multi-user.target

Let me know if this works.

2
  • Thank you for your answer. It didn't unfortunately. I don't think After=plymouth-start.service helps too much here, since when rebooting / shutting down the targeted plymouth session should be the session started by plymouth-reboot.service / plymouth-shutdown.service, no? I tried changing that to After=plymouth-reboot.service, and I also removed Before=shutdown.target as I'm attempting to display a message on reboot currently. Note that if I introduce a sleep command I'm able to see the service executing when hitting ESC, so I'm fairly sure the command runs at the right time Commented Aug 26, 2024 at 1:25
  • Anyways I also attempted removing --mode=reboot from plymouth-reboot.service via systemctl edit, thinking it may have something to do with that, and that didn't work either. I'm under the impression that I'm not targeting the plymouth session correctly somehow. Commented Aug 26, 2024 at 1:27

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.