ubuntu 20.04 搭建crash dump问题分析环境

这篇具有很好参考价值的文章主要介绍了ubuntu 20.04 搭建crash dump问题分析环境。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

主机环境和内核版本信息:

test@test:~/software/crash$ uname -r
5.15.0-74-generic
test@test:~/software/crash$

test@test:~/software/crash$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.6 LTS"
test@test:~/software/crash$

1 安装依赖软件

参考了Ubuntu Kernel crash dump这篇文章

1.1 linux-dump

sudo apt install linux-crashdump

1.2 kexec-tools

sudo apt-get install kexec-tools

1.3 安装crash工具

sudo apt install crash

1.4 安装gdb调试工具

sudo apt-get install gdb

1.5 安装ubuntu内核调试符号

sudo apt-get install linux-image-$(uname -r)-dbgsym

如果通过上面的命令安装ubuntu内核调试符号,则需要通过下面的方法去安装,参考文章:安装ubuntu内核调试符号

1.5.1 GPG 秘钥导入

确保您拥有系统的 GPG 密钥。适用于16.04 及更高版本的 Ubuntu :

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C8CAB6595FDFF622

对于旧的发布版本:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys ECDCAD72428D7C0

1.5.2 添加仓库配置

codename=$(lsb_release -c | awk  '{print $2}')
sudo tee /etc/apt/sources.list.d/ddebs.list << EOF
deb http://ddebs.ubuntu.com/ ${codename}      main restricted universe multiverse
deb http://ddebs.ubuntu.com/ ${codename}-security main restricted universe multiverse
deb http://ddebs.ubuntu.com/ ${codename}-updates  main restricted universe multiverse
deb http://ddebs.ubuntu.com/ ${codename}-proposed main restricted universe multiverse
EOF

1.5.3 更新软件包

sudo apt-get update

1.5.4 下载和安装内核调试符号

sudo apt-get install linux-image-$(uname -r)-dbgsym

1.5.5 验证内核调试符号已经被安装

包含调试信息的文件名为 vmlinux-XXX-debug,其中 XXX 是内核版本。该文件存储在 /usr/lib/debug/boot 目录下。

1.6 配置转储内存大小

修改配置/etc/default/grub.d/kdump-tools.cfg,以支持kernel crash dump现场保存。

GRUB_CMDLINE_LINUX_DEFAULT="$GRUB_CMDLINE_LINUX_DEFAULT crashkernel=384M-:512M"

2 触发系统异常验证

2.1 开启kdump服务

systemctl start kdump-tools-dump.service

systemctl enable kdump-tools-dump.service

2.2 查看kdump服务当前的状态

test@test:~/software/crash$ service kdump-tools-dump status
● kdump-tools-dump.service - Kernel crash dump capture service
     Loaded: loaded (/lib/systemd/system/kdump-tools-dump.service; static; vendor preset: enabled)
     Active: active (exited) since Tue 2023-11-14 10:19:58 CST; 56s ago
   Main PID: 126662 (code=exited, status=0/SUCCESS)
      Tasks: 0 (limit: 37610)
     Memory: 0B
     CGroup: /system.slice/kdump-tools-dump.service

1114 10:19:58 test systemd[1]: Starting Kernel crash dump capture service...
1114 10:19:58 test kdump-tools[126662]: Starting kdump-tools:
1114 10:19:58 test kdump-tools[126669]:  * Cannot change symbolic links when kdump is loaded
1114 10:19:58 test systemd[1]: Finished Kernel crash dump capture service.
test@test:~/software/crash$

2.3 手动触发crash dump

2.3.1 切换为 root 用户

sudo -s

2.3.2 触发crash dump

echo 1 > /proc/sys/kernel/sysrq

echo c > /proc/sysrq-trigger

3 kernel dump文件分析

3.1 crash dump文件的位置

test@test:~/software/crash$ ls /var/crash/
202311132045  kexec_cmd                                         linux-image-5.15.0-74-generic-202311132357.crash          _opt_kingsoft_wps-office_office6_wpscloudsvr.1000.uploaded  _usr_bin_crash.0.uploaded
202311132231  linux-image-5.15.0-74-generic-202311132045.crash  _opt_kingsoft_wps-office_office6_wpscloudsvr.1000.crash   _usr_bin_crash.0.crash
202311132357  linux-image-5.15.0-74-generic-202311132231.crash  _opt_kingsoft_wps-office_office6_wpscloudsvr.1000.upload  _usr_bin_crash.0.upload
test@test:~/software/crash$

3.2 crash工具分析crash dump文件

test@test:~/software/crash$ sudo crash -d /usr/bin/gdb /usr/lib/debug/boot/vmlinux-5.15.0-74-generic /var/crash/202311132357/dump.202311132357 

crash 8.0.3++
Copyright (C) 2002-2022  Red Hat, Inc.
Copyright (C) 2004, 2005, 2006, 2010  IBM Corporation
Copyright (C) 1999-2006  Hewlett-Packard Co
Copyright (C) 2005, 2006, 2011, 2012  Fujitsu Limited
Copyright (C) 2006, 2007  VA Linux Systems Japan K.K.
Copyright (C) 2005, 2011, 2020-2022  NEC Corporation
Copyright (C) 1999, 2002, 2007  Silicon Graphics, Inc.
Copyright (C) 1999, 2000, 2001, 2002  Mission Critical Linux, Inc.
Copyright (C) 2015, 2021  VMware, Inc.
This program is free software, covered by the GNU General Public License,
and you are welcome to change it and/or distribute copies of it under
certain conditions.  Enter "help copying" to see the conditions.
This program has absolutely no warranty.  Enter "help warranty" for details.
 
GNU gdb (GDB) 10.2
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...

      KERNEL: /usr/lib/debug/boot/vmlinux-5.15.0-74-generic
    DUMPFILE: /var/crash/202311132357/dump.202311132357  [PARTIAL DUMP]
        CPUS: 16
        DATE: Mon Nov 13 23:56:58 CST 2023
      UPTIME: 00:11:00
LOAD AVERAGE: 0.71, 0.84, 0.58
       TASKS: 1636
    NODENAME: test
     RELEASE: 5.15.0-74-generic
     VERSION: #81~20.04.2-Ubuntu SMP Fri May 26 19:56:20 UTC 2023
     MACHINE: x86_64  (2900 Mhz)
      MEMORY: 31.8 GB
       PANIC: "Kernel panic - not syncing: sysrq triggered crash"
         PID: 10269
     COMMAND: "bash"
        TASK: ffff89a4d1334d40  [THREAD_INFO: ffff89a4d1334d40]
         CPU: 0
       STATE: TASK_RUNNING (PANIC)

crash> bt
PID: 10269    TASK: ffff89a4d1334d40  CPU: 0    COMMAND: "bash"
 #0 [ffff94d441397c48] machine_kexec at ffffffff9688afe0
 #1 [ffff94d441397ca8] __crash_kexec at ffffffff96998c02
 #2 [ffff94d441397d78] panic at ffffffff974cf4b6
 #3 [ffff94d441397df8] sysrq_handle_crash at ffffffff96feea5a
 #4 [ffff94d441397e08] __handle_sysrq.cold at ffffffff97524bf2
 #5 [ffff94d441397e50] write_sysrq_trigger at ffffffff96fef548
 #6 [ffff94d441397e68] proc_reg_write at ffffffff96c23b57
 #7 [ffff94d441397e88] vfs_write at ffffffff96b83a76
 #8 [ffff94d441397ec0] ksys_write at ffffffff96b85de7
 #9 [ffff94d441397f00] __x64_sys_write at ffffffff96b85e8a
#10 [ffff94d441397f10] do_syscall_64 at ffffffff97571d39
#11 [ffff94d441397f28] do_syscall_64 at ffffffff97571d49
#12 [ffff94d441397f50] entry_SYSCALL_64_after_hwframe at ffffffff97600099
    RIP: 00007fc202171077  RSP: 00007ffe9fcff018  RFLAGS: 00000246
    RAX: ffffffffffffffda  RBX: 0000000000000002  RCX: 00007fc202171077
    RDX: 0000000000000002  RSI: 000055c60be1a9e0  RDI: 0000000000000001
    RBP: 000055c60be1a9e0   R8: 000000000000000a   R9: 0000000000000001
    R10: 000055c60b144017  R11: 0000000000000246  R12: 0000000000000002
    R13: 00007fc2022506a0  R14: 00007fc20224c4a0  R15: 00007fc20224b8a0
    ORIG_RAX: 0000000000000001  CS: 0033  SS: 002b
crash>

4 遇到的问题以及解决办法

4.1 ‘makeinfo’ is missing on your system

4.1.1 问题现象

/home/test/software/crash/gdb-10.2/missing: line 81: makeinfo: command not found
WARNING: 'makeinfo' is missing on your system.
         You should only need it if you modified a '.texi' file, or
         any other file indirectly affecting the aspect of the manual.
         You might want to install the Texinfo package:
         <http://www.gnu.org/software/texinfo/>
         The spurious makeinfo call might also be the consequence of
         using a buggy 'make' (AIX, DU, IRIX), in which case you might
         want to install GNU make:
         <http://www.gnu.org/software/make/>
make[5]: *** [Makefile:542: bfd.info] Error 127
make[4]: *** [Makefile:1643: info-recursive] Error 1
make[3]: *** [Makefile:2771: all-bfd] Error 2
make[3]: *** Waiting for unfinished jobs....
config.status: creating Makefile
config.status: creating import/Makefile
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing default commands
make[2]: *** [Makefile:860: all] Error 2
crash build failed
make[1]: *** [Makefile:263: gdb_merge] Error 1
make: *** [Makefile:254: all] Error 2

4.1.2 解决方法

sudo apt-get update
sudo apt-get install texinfo

4.2 crash工具和主机安装的gdb版本不一致导致的异常

4.2.1 问题的现象

GNU gdb (GDB) 7.6
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu"...

WARNING: kernel relocated [344MB]: patching 145829 gdb minimal_symbol values

please wait... (patching 145829 gdb minimal_symbol values) Segmentation fault

test@test:~/software/crash$ gdb --version
GNU gdb (Ubuntu 10.2-0ubuntu1~20.04~1) 10.2
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
test@test:~/software/crash$

4.2.2 解决办法

sudo apt purge crash

git clone https://github.com/crash-utility/crash.git

cd crash

make -j8
sudo make install
crash --version

4.3 /dev/mem: Operation not permitted

4.3.1 问题的现象

sudo crash /usr/lib/debug/boot/vmlinux-5.15.0-74-generic

crash 7.2.8
Copyright (C) 2002-2020  Red Hat, Inc.
Copyright (C) 2004, 2005, 2006, 2010  IBM Corporation
Copyright (C) 1999-2006  Hewlett-Packard Co
Copyright (C) 2005, 2006, 2011, 2012  Fujitsu Limited
Copyright (C) 2006, 2007  VA Linux Systems Japan K.K.
Copyright (C) 2005, 2011  NEC Corporation
Copyright (C) 1999, 2002, 2007  Silicon Graphics, Inc.
Copyright (C) 1999, 2000, 2001, 2002  Mission Critical Linux, Inc.
This program is free software, covered by the GNU General Public License,
and you are welcome to change it and/or distribute copies of it under
certain conditions.  Enter "help copying" to see the conditions.
This program has absolutely no warranty.  Enter "help warranty" for details.
 

crash: /dev/mem: Operation not permitted

4.3.2 解决方法

参考1.6节,修改/etc/default/grub.d/kdump-tools.cfg文件,添加下面的配置以支持

GRUB_CMDLINE_LINUX_DEFAULT="$GRUB_CMDLINE_LINUX_DEFAULT` crashkernel=384M-:512M"

然后修改/dev/mem的权限文章来源地址https://www.toymoban.com/news/detail-754495.html

sudo chmod 777 /dev/mem

到了这里,关于ubuntu 20.04 搭建crash dump问题分析环境的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 从头搭建Android源码编译环境(Ubuntu 18.04 / 20.04 / 22.04)

    在新安装的Ubuntu上(版本20.04LTS),完成搭建Android源码编译环境步骤如下。 顺带说一句,当前用的比较多的Ubuntu是18.04和20.04,在实际项目中一直在用,可用性和稳定性都没问题。 最新的Ubuntu22.04版本,系统默认的二进制库变化比较大,编译Android源码有问题(实测过,没细研

    2024年02月06日
    浏览(100)
  • ubuntu20.04一键安装VScode搭建ROS编程环境

    VSCode 全称 Visual Studio Code,是微软出的一款轻量级代码编辑器,免费、开源而且功能强大。它支持几乎所有主流的程序语言的语法高亮、智能代码补全、自定义热键、括号匹配、代码片段、代码对比 Diff、GIT 等特性,支持插件扩展,并针对网页开发和云端应用开发做了优化。

    2023年04月24日
    浏览(41)
  • RK356x基于Ubuntu20.04搭建ROS开发环境

    CPU:RK356x 操作系统:arm64 Ubuntu20.04 1、首先确保开发板是可以联网的。

    2024年01月20日
    浏览(35)
  • ubuntu20.04搭建ROS+UE4+airsim环境

    前两天搭建了ubuntu20.04下ue4+ROS+airsim环境,在这里记录一下,方便后面自己查阅。 主要过程参见链接:Ubuntu18.04搭建AirSim+ROS仿真环境_我只是一只自动小青蛙的博客-CSDN博客_airsim ros 我遇到的问题(根据引文中的标题): 1、github于epic账号绑定问题:需要在epic账号设置中绑定

    2024年02月10日
    浏览(37)
  • fabric 环境快速搭建--Ubuntu20.04系统下使用fabric官方脚本搭建

    由于是初识hyper ledger fabric在安装的时候遇到了很多的问题,最后在师兄的帮助下终于删了从头到尾安装了一遍,因此想记录一下,并且给和我遇到相同问题的小伙伴提供一些帮助。如果你是萌新,找我就对啦! 直接去官方下载即可 其他帖子上面有很多详细步骤,这里不多赘

    2024年02月14日
    浏览(32)
  • Ubuntu20.04 搭建L2TP+IPsec环境

    安装l2tp和strongswan。 sudo apt install xl2tpd sudo apt install strongswan 1)编辑**/etc/ipsec.conf** 2)编辑**/etc/ipsec.secrets** , 设置ipsec的预共享秘钥 编辑**/etc/xl2tpd/xl2tpd.conf** 1) 编辑PPP配置文件(例如上文中的**/etc/ppp/options.xl2tpd**)。 2)编辑**/etc/ppp/chap-secrets**,添加VPN访问用户密码 # 重启服

    2024年02月04日
    浏览(41)
  • 基于Ubuntu20.04搭建OpenHarmony v3.0.6的qemu仿真环境

    出于个人兴趣,也出于对国产操作系统的好奇,想尝试一下以LiteOS为内核的Openharmony。但过程相当不顺利,主要原因是官方文档内容组织的不敢恭维。挺好的东西,不把说明书写好,让用户怎么用?我研究的核心问题就一个:如何在基于Qemu仿真的Openharmony中输出一个hello worl

    2024年02月09日
    浏览(30)
  • EAP-TLS实验之Ubuntu20.04环境搭建配置(FreeRADIUS3.0)(一)

            年后开始准备EAP-TLS 802.1x认证的事情,年前搭建了Windows Server 2019预为认证服务器,参考了《在 Windows Server 上搭建 AD 域控制器 - KOBIN 技术随笔》及《Windows Server 搭建 RADIUS 认证服务器 - 知乎》及《WINDOWS SERVER 2012证书服务安装配置_cep的身份验证类型-CSDN博客》及《W

    2024年02月22日
    浏览(24)
  • Ubuntu20.04搭建PX4仿真环境及XTDrone开发平台(最详细最明白)

    PX4-Autopilot仿真平台是由PX4官方提供的集虚拟px4固件、真机烧录固件、gazebo环境及模型于一体的平台,用户可以自己编写程序,通过mavros接口与虚拟px4固件进行mavlink协议的通讯,并在gazebo中显示虚拟世界和模型。因此PX官方手册里给了一个经典的例程:offboard.cpp和offboard.py,让

    2024年02月04日
    浏览(90)
  • 【SDN】最新!手把手零基础在Ubuntu 20.04搭建SDN环境(全网最详细)/Floodlight/Mininet/sFlow

    想在Linux下搭建SDN环境,几乎把中文互联网所有相关教程都看了,用了一周时间才弄好,写下这篇文章帮助大家排坑。包括搭建 Floodlight 和 Mininet , sFlow。 网上教程很多,就不展开了。 参考了 Unbuntu下Java环境搭建-CSDN博客 Linux之Ubuntu20.04安装Java JDK8的两种方式-CSDN博客 一 更

    2024年03月12日
    浏览(106)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包