1.9. 从救援环境中生成 sos 报告
如果一个 Red Hat Enterprise Linux(RHEL)主机无法正确引导,您可以将主机引导至 救援环境 中来收集 sos 报告。
使用救援环境,您可以在 /mnt/sysroot 下挂载目标系统,访问其内容,并运行 sos report 命令。
先决条件
- 如果主机是裸机服务器,则需要对该机器进行的物理访问。
- 如果主机是虚拟机,您需要访问虚拟机管理程序中的虚拟机设置。
- RHEL 安装源,如 ISO 镜像文件、安装 DVD、netboot CD 或提供 RHEL 安装树的 Preboot Execution Environment(PXE)配置。
流程
- 从安装源引导主机。
-
在安装介质的引导菜单中,选择
Troubleshooting选项。 -
在故障排除菜单中选择
Rescue a Red Hat Enterprise Linux system选项。 在救援菜单中,选择
1并按 Enter 键继续,并在/mnt/sysroot目录下挂载系统。… 1) Continue 2) Read-only mount 3) Skip to shell 4) Quit (Reboot) Please make a selection from the above: 1提示时按 Enter 键进行一个 shell。
Rescue Shell Your system has been mounted under /mnt/sysroot. If you would like to make the root of your system the root of the activate system, run the command: chroot /mnt/sysroot Warning: The rescue shell will trigger SELinux autorelabel on the subsequent boot. Add "enforcing=0" on the kernel command line for autorelabel to work properly. When finished, please exit from the shell and your system will reboot. Please press ENTER to get a shell: bash-5.2#使用
chroot命令将救援会话的显式根目录改为/mnt/sysroot目录。Rescue Shell … Please press ENTER to get a shell: bash-5.2# chroot /mnt/sysimage/可选:您的网络可能在初始救援环境中没有启动,因此请确保先设置它。例如,如果网络需要静态 IP 地址,并且您希望通过网络传输
sos报告,请配置网络:确定您要使用的以太网设备:
# ip link show … 2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000 link/ether 52:54:00:74:79:56 brd ff:ff:ff:ff:ff:ff为网络接口分配一个 IP 地址,并设置默认网关。例如,如果您要将子网为 255.255.255.0(其 CIDR 为 24)的 IP 地址 192.168.0.1 添加到设备 enp1s0,请输入:
# ip address add <192.168.0.1/24> dev <enp1s0> # ip route add default via <192.168.0.254>在
/etc/resolv.conf文件中添加nameserver条目,例如:nameserver <192.168.0.5>
运行
sos report命令并按照屏幕的说明进行操作。您可以添加--upload选项,以在生成后将sos报告立即转移到红帽。bash-5.2# sos report sos report (version 4.8.2) This command will collect system configuration and diagnostic information from this Fedora Linux system. For more information on the Fedora Project visit: Community Website : https://fedoraproject.org/ Community Forums : https://discussion.fedoraproject.org/ The generated archive may contain data considered sensitive and its content should be reviewed by the originating organization before being passed to any third party. No changes will be made to system configuration. Press ENTER to continue, or CTRL-C to quit.可选:如果您已经向红帽开了一个技术支持问题单,请输入问题单号,以便将其嵌入到
sos报告的文件名中,如果您指定了--upload选项,且您的主机已连接到互联网,它将被上传到该问题单中。如果您没有问题单号,请将此字段留空。输入问题单号是可选的,不会影响sos实用程序的操作。sos report (version 4.8.2) … Press ENTER to continue, or CTRL-C to quit. Optionally, please enter the case id that you are generating this report for []:记录下控制台输出末尾显示的
sos报告文件名称。Finished running plugins Creating compressed archive… Your sosreport has been generated and saved in: /var/tmp/secured-sosreport-unused-2025-05-14-lofqhen.tar.xz Size 9.30MiB Owner root sha256 bf303917b689b13f0c059116d9ca55e341d5fadcd3f1473bef7299c4ad2a7f4f Please send this file to your support representative. bash-5.2#-
如果您的主机还没有连接到互联网,使用
scp将sos报告传送到网络中的另一台主机,然后将其上传到红帽技术支持问题单。
验证
验证
sos工具是否在/var/tmp/目录中创建了一个存档。$ ls -l /var/tmp/sosreport* -rw-r—r--. 1 root root 65 Mar 14 2025 /var/tmp/sosreport-example.hostname-2025-05-14-lofqhen.tar.xz.sha256 -rw-------. 1 root root 17036176 Mar 14 2025 /var/tmp/sosreport-example.hostname-2025-05-14-lofqhen.tar.xz5-14-lofqhen.tar.xz