如何让 Plymouth 在系统启动时显示 FSCK 消息?

如何让 Plymouth 在系统启动时显示 FSCK 消息?

我创建了一个自定义的 Plymouth 主题(基于 MIB Ossigeno),配置为通过实现消息具有以下格式的通信协议来处理来自 systemd-fsckd 的 fsck 消息:

fsckd:<num_devices>:<progress>:<string> 

根据文档(8-systemd-fsckd.service

执行时,在测试模式(“启动后”)下,使用以下命令:

plymouthd; plymouth --show-splash ; for ((I=0; I<10; I++)); do plymouth --update=fsck:sda1:$I ; sleep 1; done; plymouth quit

通过特殊的 FSCK 消息,plymouth 会显示所需的消息,例如“正在检查磁盘 1 of 1(2% 完成)”。看:普利茅斯

在此输入图像描述 到目前为止,一切都很好。

但重新启动系统时,fsck 消息不会显示在 bootsplash 上。但是,如果我按 Esc 键切换到控制台,则可以看到 fsck 进度消息。

在此输入图像描述

为了强制 fsck 在启动时运行,我交替使用une2fs 和 grub ( GRUB_CMDLINE_LINUX_DEFAULT="quiet splash fsck.mode=force fsck.repair=yes") 来查看是否有任何影响。

由于某种原因,fsck 和 Plymouth 之间的通信无法正常工作或工作正常。默认主题 futureprototype 也不起作用。我猜问题出在 systemd-fsckd 中,如何确定 systemd-fsckd 的任务是否在启动时执行?,是否有报告或状态显示是否发现任何问题?

我查看 /run/initramfs/fsck.log (这看起来不错):

~# cat /run/initramfs/fsck.log
Log of fsck -C -f -y -T -t ext4 /dev/sda1 
Wed Feb 28 15:26:27 2024

e2fsck 1.47.0 (5-Feb-2023)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/sda1: 212266/593344 files (0.2% non-contiguous), 1705537/2371072 blocks

Wed Feb 28 15:26:30 2024

杂志...

~# journalctl -u systemd-fsck*
-- Boot f8b976dfd857400085057901577c56f9 --
feb 28 10:40:53 debian12 systemd[1]: Started systemd-fsckd.service - File System Check Daemon to report status.
feb 28 10:41:23 debian12 systemd[1]: systemd-fsckd.service: Deactivated successfully.
feb 28 10:51:02 debian12 systemd[1]: Started systemd-fsckd.service - File System Check Daemon to report status.
feb 28 10:51:32 debian12 systemd[1]: systemd-fsckd.service: Deactivated successfully

和系统控制

~# systemctl status systemd-fsckd.socket
● systemd-fsckd.socket - fsck to fsckd communication Socket
     Loaded: loaded (/lib/systemd/system/systemd-fsckd.socket; static)
     Active: active (listening) since Wed 2024-02-28 15:26:31 -03; 16min ago
   Triggers: ● systemd-fsckd.service
       Docs: man:systemd-fsckd.service(8)
             man:[email protected](8)
             man:systemd-fsck-root.service(8)
     Listen: /run/systemd/fsck.progress (Stream)
     CGroup: /system.slice/systemd-fsckd.socket


~# systemctl status systemd-fsckd.service
○ systemd-fsckd.service - File System Check Daemon to report status
     Loaded: loaded (/lib/systemd/system/systemd-fsckd.service; static)
     Active: inactive (dead)
TriggeredBy: ● systemd-fsckd.socket
       Docs: man:systemd-fsckd.service(8)

目的是通知用户引导过程因 fsck 的磁盘检查而延迟,并查看其进度。我已经用尽了所有资源,但在网络上什么也没找到。一般来说,我发现的只是隐藏启动消息。

~# more /etc/debian_version
10.13
~# uname -a
Linux debian 4.19.0-26-686-pae #1 SMP Debian 4.19.304-1 (2024-01-09) i686 GNU/Linux

由于不相关的原因,开发是在操作系统 Debian 10 上进行的,尽管我也尝试过使用 Debian 12 获得相同的结果。

PD:一个可能相关的细节:Debian 10 和 Debian 12 的测试都是在 Virtual Box 上的虚拟机上进行的。

更多测试:

案例一:Virtual Box 上的 Debian 10。 fsck 消息不会出现,日志显示以下内容:

root@debian:~# systemctl list-sockets | grep fsckd
/run/systemd/fsck.progress   systemd-fsckd.socket            systemd-fsckd.service

root@debian:~# journalctl -b /usr/lib/systemd/systemd-fsck
-- No entries --

root@debian:~# journalctl -b /usr/lib/systemd/systemd-fsckd
-- No entries --

root@debian:~# journalctl --boot | grep systemd-fsck*
mar 04 13:07:01 debian systemd[1]: Listening on systemd-fsckd.socket - fsck to fsckd communication Socket.
mar 04 13:07:01 debian systemd[1]: systemd-fsck-root.service - File System Check on Root Device was **skipped** because of an unmet condition check (**ConditionPathExists=!/run/initramfs/fsck-root**).

root@debian:~# cat /run/initramfs/fsck.log
Log of fsck -C -a -T -t ext4 /dev/sda1 
Mon Mar  4 13:06:59 2024
/dev/sda1: clean, 212351/593344 files, 1708897/2371072 blocks
Mon Mar  4 13:06:59 202

案例二:物理 PC (amd64) 上的 Debian 10。在这种情况下,消息是可见的,但在过程结束时只有很短的几秒钟。执行 fsck 期间不显示任何内容。

root@Dell:~# systemctl list-sockets | grep fsckd
/run/systemd/fsck.progress      systemd-fsckd.socket            systemd-fsckd.service

root@Dell:~# journalctl -b /usr/lib/systemd/systemd-fsck
-- Logs begin at Mon 2024-03-04 15:58:16 -03, end at Mon 2024-03-04 19:25:01 -03. --
mar 04 15:58:21 Dell systemd-fsck[420]: e2fsck 1.44.5 (15-Dec-2018)
mar 04 15:58:21 Dell systemd-fsck[420]: Pass 1: Checking inodes, blocks, and sizes
mar 04 15:58:21 Dell systemd-fsck[420]: Pass 2: Checking directory structure
mar 04 15:58:21 Dell systemd-fsck[420]: Pass 3: Checking directory connectivity
mar 04 15:58:21 Dell systemd-fsck[420]: Pass 4: Checking reference counts
mar 04 15:58:21 Dell systemd-fsck[420]: Pass 5: Checking group summary information
mar 04 15:58:22 Dell systemd-fsck[420]: /dev/sda1: 1034/69360 files (0.7% non-contigu

root@Dell:~# journalctl -b /usr/lib/systemd/systemd-fsckd
-- Logs begin at Mon 2024-03-04 15:58:16 -03, end at Mon 2024-03-04 19:25:01 -03. --
-- No entries --

root@Dell:~# journalctl --boot | grep systemd-fsck*
mar 04 15:58:21 Dell systemd-fsck[420]: e2fsck 1.44.5 (15-Dec-2018)
mar 04 15:58:21 Dell systemd-fsck[420]: Pass 1: Checking inodes, blocks, and sizes
mar 04 15:58:21 Dell systemd-fsck[420]: Pass 2: Checking directory structure
mar 04 15:58:21 Dell systemd-fsck[420]: Pass 3: Checking directory connectivity
mar 04 15:58:21 Dell systemd-fsck[420]: Pass 4: Checking reference counts
mar 04 15:58:21 Dell systemd-fsck[420]: Pass 5: Checking group summary information
mar 04 15:58:22 Dell systemd-fsck[420]: /dev/sda1: 1034/69360 files (0.7% non-contiguous), 189933/276480 blocks
mar 04 15:59:01 Dell systemd[1]: systemd-fsckd.service: Succeeded.

root@Dell:~# cat /run/initramfs/fsck.log
Log of fsck -C -f -y -T -t ext4 /dev/sda2
Mon Mar  4 18:57:36 2024

e2fsck 1.44.5 (15-Dec-2018)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/sda2: 673194/9551872 files (0.8% non-contiguous), 29651430/38200576 blocks

Mon Mar  4 18:58:11 2024
----------------

情况三:物理 PC (amd64) 上的 Debian 10 具有多个条目 grub 菜单(Debian 和其他带有 Windows 的可引导分区)。

root@5VQU7SN:~# systemctl list-sockets | grep fsckd
/run/systemd/fsck.progress      systemd-fsckd.socket            systemd-fsckd.service

root@5VQU7SN:~# journalctl -b /usr/lib/systemd/systemd-fsck
-- Logs begin at Mon 2024-03-04 15:38:25 -03, end at Mon 2024-03-04 20:39:47 -03. --
-- No entries --

root@5VQU7SN:~# journalctl -b /usr/lib/systemd/systemd-fsckd
-- Logs begin at Mon 2024-03-04 15:38:25 -03, end at Mon 2024-03-04 20:39:47 -03. --
-- No entries --

root@5VQU7SN:~# journalctl --boot | grep systemd-fsck*
-- No entries --

root@5VQU7SN:~# cat /run/initramfs/fsck.log
Log of fsck -C -f -y -T -t ext4 /dev/sda6 
Mon Mar  4 18:37:59 2024

e2fsck 1.44.5 (15-Dec-2018)
/dev/sda6: recovering journal
Clearing orphaned inode 15992282 (uid=1000, gid=1000, mode=0100644, size=32768)
Clearing orphaned inode 15991323 (uid=1000, gid=1000, mode=0100600, size=460)
Clearing orphaned inode 15990858 (uid=1000, gid=1000, mode=0100644, size=4132)
Clearing orphaned inode 15990852 (uid=1000, gid=1000, mode=0100600, size=131072)
Clearing orphaned inode 15990840 (uid=1000, gid=1000, mode=0100644, size=4132)
Clearing orphaned inode 15990827 (uid=1000, gid=1000, mode=0100644, size=4132)
Clearing orphaned inode 15990826 (uid=1000, gid=1000, mode=0100644, size=4132)
Clearing orphaned inode 15990859 (uid=1000, gid=1000, mode=0100644, size=4132)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
Free blocks count wrong (112010854, counted=112010689).
Fix? yes

Free inodes count wrong (28961618, counted=28961585).
Fix? yes


/dev/sda6: ***** FILE SYSTEM WAS MODIFIED *****
/dev/sda6: 292047/29253632 files (0.3% non-contiguous), 4981311/116992000 blocks
fsck exited with status code 1

Mon Mar  4 18:38:19 2024
----------------

这个问题变得相当复杂,我不知道该往哪里推进。希望有专业的同学能帮我解决这个问题。

状态更新:

我发现默认的普利茅斯主题可以在另一台电脑上运行,当我安装我的主题时,它也可以运行。我花了几天时间检查 grub、fsck 和 plymouth 配置,但找不到区别。直到我注意到在那台 PC 上,/boot 目录安装在与根目录不同的分区上。在物理和虚拟 PC 上从头开始安装 Debian,分别使用 /boot。它成功了!难道是systemd-fsck的bug?

相关内容