消息来源:RHEL issue report RHEL-17164: 根据刚刚发布的公告,RHEL 7.x 版本升级systemd到版本systemd-219-78.el7_9.8后会出现系统无法启动的状况,目前问题依然在发生,可能会影响所有已知安装该systemd版本的RHEL 7.x。请按照本文描述的方法进行验证和解决。
症状:
RedHat/CentOS 7 更新到systemd-219-78.el7_9.8 后系统无法启动,错误信息如下:
auto
Mounting /sysroot/sysroot/usr...
[FAILED] Failed to mount /sysroot/sysroot/usr.
See 'systemctl status sysroot-sysroot-usr.mount' for details.
[DEPEND] Dependency failed for Initrd File Systems.
:
[ 1.781938] systemd[1]: No /sbin/init, trying fallback
[ 1.782970] systemd[1]: Failed to execute /bin/sh, giving up: No such file or directory
AUTO
7 lines|350 chars
根本原因:
该版本的systemd-fstab-generator错误的将sysroot-usr.mount生成为sysroot-sysroot-usr.mount
auto
cat /run/systemd/generator/sysroot-sysroot-usr.mount
# Automatically generated by systemd-fstab-generator
[Unit]
SourcePath=/sysroot/etc/fstab
Documentation=man:fstab(5) man:systemd-fstab-generator(8)
Before=initrd-fs.target
[Mount]
What=/dev/mapper/rhel-usr
# Canonicalized from /sysroot/usr
Where=/sysroot/sysroot/usr
Type=xfs
AUTO
13 lines|343 chars
解决方法:
如果已经升级到该版本并受到了影响,请尝试在单用户模式/救援模式下强制降级systemd并重建initramfs:
auto
yum downgrade systemd*-219-78.el7_9.7.x86_64 libgudev1
dracut -f -v initramfs-3.10.0-1160.105.1.el7.x86_64.img 3.10.0-1160.105.1.el7.x86_64
AUTO
2 lines|140 chars
** 以上只是一个示例。将3.10.0-1160.105.1.el7替换为/boot目录下显示的次级新内核版本(可通过执行命令 ls -l /boot 来查看)。
该问题已经在新版本的systemd中得到修复,如果您期望尽可能的避免此问题发生,您可以在/etc/yum.conf进行配置摆出这个版本的systemd:
auto
vi /etc/yum.conf
exclude=systemd*-219-78.el7_9.8,libgudev1-219-78.el7_9.8
AUTO
3 lines|76 chars
参考文献:
RHBA-2023:7468 – Bug Fix Advisory – Red Hat Customer Portal