linux内核调用dma搬移数据到物理地址 Linux内核调试方法
0
2026-06-18
kdump is the kernel crash dump mechanism officially supported by the mainstream distribution, kdmp is a typo;需要通过crashkernel参数预留内存(例如Fedora CoreOS建议crashkernel=300M),重新配置服务并转储路径,最后验证内核加载能力的捕获。 CoreOS、Ubuntu、SLES)官方支持的内核崩溃导出机制,kdmp不存在——这是一个常见的拼写错误或易混淆的词,实际是kdump。 Confirm whether the system has enabled kdump kernel parameters. /proc/cmdline
If the output is empty, the explanation is no memory, then all configuration is invalid.常见错误现象:systemctl status kdump 显示inactive(死亡),日志中反复出现Failed to Reserve crashkernel memory。
不同场景推荐值:普通物理机或虚拟机(≥4GB内存):使用crashkernel=300M更稳定,Fedora CoreOS上crashkernel=auto常只留64M,不足以捕获完整vmcore内存≥16GB服务器:可设置为crashkernel=512M,避免压缩失败或转移存储被截断的ARM64或龙芯等。 非x86架构:必须指定偏移量,如crashkernel=256M@32M,否则有可能由于EFI内存布局冲突,导致内核捕获无法加载,修改grub并更新启动配置。 grub2-mkconfig 是最好的方法。
步骤必须严格按顺序:编辑 /etc/default/grub,在 GRUB_CMDLINE_LINUX 中添加或替换 crashkernel=300M,执行 sudo grub2-mkconfig -o /boot/grub2/grub.cfg (BIOS) 或 sudo grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg (UEFI) and verify immediately after restarting: cat /proc/cmdline | grep crashkernel —— 你必须看到有效值,而不是旧值
注意:在Fedora CoreOS和其他不可变系统中,使用rpm-ostree kargs --append=crashkernel=300M,然后systemctl重新启动,grub文件将被下次更新覆盖。
CentOS Linux 7.9.2009
CentOS Linux 7.9.2009是传统CentOS Linux 7的最后一个主要版本,也是许多企业历史服务器中仍然可以找到的系统版本。 7 Ended maintenance on June 30th, 2024. Now it will continue to be used.该版本比较适合老业务迁移、历史环境恢复或者兼容性测试。写进根分地,愑爆/导致系统无法重启。
安全做法:确保/var/crash位于有≥2GB可用空间(vmcore常达1-3GB)的文件系统或NFS或SSH远程存储,/etc/kdump.conf只能保留一个目标(ext4、nfs、ssh) 三选一), 多写 will cause the service to fail to start up. kdump.service,只启用不启动,电影是不活动
启动后检查:systemctl status kdump 合合手机活动(退出),不活动(运行) —— 这是正常行为,因为 kdump 是一次性服务,只有在崩溃时才会触发。测试之前,需要验证是否可以加载内核捕获
手动触发 echo c > /proc/sysrq-trigger 前,先电影:
sudo kdumpctl debug
会尝试模拟当前内核中内核和initramfs的加载。
失败通常是由于: makedumpfile 版本不兼容(如 kernel 是 6.6,但 makedumpfile 是 6.4,缺少新的内存映射支持)/boot/initramfs-$(uname -r)-kdump.img 丢失(需要 kexec-tools 或运行 dracut --force --regenerate-all) SELinux 拦截了 kdump 的内存访问(暂时禁用测试:sudo setenforce 0)