Bug 2445 - Anolis OS 23 20221013测试镜像安装后无法正常启动
Summary: Anolis OS 23 20221013测试镜像安装后无法正常启动
Status: RESOLVED FIXED
Alias: None
Product: Anolis OS 23
Classification: Anolis OS
Component: Images&Installations (show other bugs) Images&Installations
Version: 23.0
Hardware: All Linux
: P3-Medium S3-normal
Target Milestone: ---
Assignee: xuchunmei
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-10-19 19:07 UTC by xuchunmei
Modified: 2022-10-19 19:25 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description xuchunmei alibaba_cloud_group 2022-10-19 19:07:22 UTC
Description of problem:

使用20221013测试镜像ISO进行安装后,无法正常启动。initrd-switch-root服务启动失败。
通过查看启动参数,发现没有指定root分区,启动参数如下:
linux ($root)/vmlinuz-5.10.134-12.1.an23.x86_64 inst.stage2-hd:LABEL=anolis-23-x86-64-dvd quiet

Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:
Comment 1 xuchunmei alibaba_cloud_group 2022-10-19 19:25:57 UTC
强制修改启动参数,添加root=/dev/mapper/ao_anolis-root后系统能够正常启动,说明系统安装没有问题,问题出在grub启动参数。

出问题的grub2版本:grub2-2.06-5.an23

在安装内核时,内核脚本会去生成grub bls配置,/boot/loader/entries/xxx-`uname -r`.conf文件中会包含内核启动参数。具体执行的脚本可通过rpm -q kernel-core --scripts查看

在系统启动后,手动安装内核,发现bls的配置中的options不对,并非默认的/etc/default/grub文件中的GRUB_CMDLINE_LINUX选项中的内容。进一步修改该选项值,通过grub2-mkconfig -o /boot/grub2/grub.cfg执行后,发现修改后的GRUB_CMDLINE_LINUX选项内容并未在/boot/loader/entries/xxx-`uname -r`.conf文件中生效。

进一步分析grub2-mkconfig的流程,发现在更新过程中,获取bls配置后执行/usr/sbin/grub2-rpm-sort后数据被清空。由此判断/usr/sbin/grub2-rpm-sort命令的问题。

通过debug后发现strchrnul函数异常,使用该接口需要#define _GNU_SOURCE,具体可以参考fc的修复:
https://src.fedoraproject.org/rpms/grub2/blob/rawhide/f/0218-rpm-sort-add-prereqs-for-declaration-of-strchrnul.patch

grub2修复pr:
https://gitee.com/src-anolis-os/grub2/pulls/26