1.9. 从救援环境中生成 sos 报告


如果一个 Red Hat Enterprise Linux(RHEL)主机无法正确引导,您可以将主机引导至 救援环境 中来收集 sos 报告。

使用救援环境,您可以在 /mnt/sysroot 下挂载目标系统,访问其内容并运行 sos report 命令。

先决条件

  • 如果主机是裸机服务器,则需要对该机器进行的物理访问。
  • 如果主机是虚拟机,您需要访问虚拟机管理程序中的虚拟机设置。
  • RHEL 安装源,如 ISO 镜像文件、安装 DVD、netboot CD 或提供 RHEL 安装树的 Preboot Execution Environment(PXE)配置。

流程

  1. 从安装源引导主机。
  2. 在安装介质的引导菜单中,选择 Troubleshooting 选项。
  3. 在故障排除菜单中选择 Rescue a Red Hat Enterprise Linux system 选项。
  4. 在 Rescue 菜单中,选择 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
    Copy to Clipboard Toggle word wrap
  5. 提示时按 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#
    Copy to Clipboard Toggle word wrap
  6. 使用 chroot 命令将救援会话的显式根目录改为 /mnt/sysroot 目录。

    Rescue Shell
    …​
    Please press ENTER to get a shell:
    bash-5.2# chroot /mnt/sysimage/
    Copy to Clipboard Toggle word wrap
  7. 可选:您的网络可能在初始救援环境中没有启动,因此请确保先设置它。例如,如果网络需要静态 IP 地址,并且您希望通过网络传输 sos 报告,请配置网络:

    1. 确定您要使用的以太网设备:

      # 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
      Copy to Clipboard Toggle word wrap
    2. 为网络接口分配一个 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>
      Copy to Clipboard Toggle word wrap
    3. /etc/resolv.conf 文件中添加 nameserver 条目,例如:

      nameserver <192.168.0.5>
      Copy to Clipboard Toggle word wrap
  8. 运行 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.
    Copy to Clipboard Toggle word wrap
  9. 可选:如果您已经向红帽开了一个技术支持问题单,请输入问题单号,以便将其嵌入到 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 []:
    Copy to Clipboard Toggle word wrap
  10. 记录下控制台输出末尾显示的 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#
    Copy to Clipboard Toggle word wrap
  11. 如果您的主机还没有连接到互联网,使用 scpsos 报告传送到网络中的另一台主机,然后将其上传到红帽技术支持问题单。

验证

  • 验证 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
    Copy to Clipboard Toggle word wrap
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat