ubuntu 20.04 启用kdump服务及下载vmlinux

本文在ubuntu20.04上安装kdump相关服务及调试内核所需的vmlinux文件,然后启用kdump服务。

1、安装

zyg@zyg:~$ sudo apt install linux-crashdump

在弹窗菜单中选择yes安装。

2、查看kdump配置

zyg@zyg:~$ kdump-config show
DUMP_MODE:        kdump
USE_KDUMP:        1
KDUMP_SYSCTL:     kernel.panic_on_oops=1
KDUMP_COREDIR:    /var/crash
crashkernel addr: 0x
   /var/lib/kdump/vmlinuz: symbolic link to /boot/vmlinuz-5.4.0-60-generic
kdump initrd: 
   /var/lib/kdump/initrd.img: symbolic link to /var/lib/kdump/initrd.img-5.4.0-60-generic
current state:    ready to kdump

kexec command:
  /sbin/kexec -p --command-line="BOOT_IMAGE=/vmlinuz-5.4.0-60-generic root=/dev/mapper/ubuntu--vg-ubuntu--lv ro maybe-ubiquity reset_devices systemd.unit=kdump-tools-dump.service nr_cpus=1 irqpoll nousb ata_piix.prefer_ms_hyperv=0" --initrd=/var/lib/kdump/initrd.img /var/lib/kdump/vmlinuz

可以看到USE_KDUMP=1,生成的vmcore文件在/var/crash下

kdump服务相关配置文件为/etc/default/kdump-tools,可以编辑该文件:

# kdump-tools configuration
# ---------------------------------------------------------------------------
# USE_KDUMP - controls kdump will be configured
#     0 - kdump kernel will not be loaded
#     1 - kdump kernel will be loaded and kdump is configured
# KDUMP_SYSCTL - controls when a panic occurs, using the sysctl 
#     interface.  The contents of this variable should be the
#     "variable=value ..." portion of the 'sysctl -w ' command.
#     If not set, the default value "kernel.panic_on_oops=1" will
#     be used.  Disable this feature by setting KDUMP_SYSCTL=" "
#     Example - also panic on oom:
#         KDUMP_SYSCTL="kernel.panic_on_oops=1 vm.panic_on_oom=1"
#
USE_KDUMP=1
#KDUMP_SYSCTL="kernel.panic_on_oops=1"


# ---------------------------------------------------------------------------
# Kdump Kernel:
# KDUMP_KERNEL - A full pathname to a kdump kernel.
# KDUMP_INITRD - A full pathname to the kdump initrd (if used).
#     If these are not set, kdump-config will try to use the current kernel
#     and initrd if it is relocatable.  Otherwise, you will need to specify 
#     these manually.
KDUMP_KERNEL=/var/lib/kdump/vmlinuz
KDUMP_INITRD=/var/lib/kdump/initrd.img


# ---------------------------------------------------------------------------
# vmcore Handling:
# KDUMP_COREDIR - local path to save the vmcore to.
# KDUMP_FAIL_CMD - This variable can be used to cause a reboot or
#     start a shell if saving the vmcore fails.  If not set, "reboot -f"
#     is the default.
#     Example - start a shell if the vmcore copy fails:
#         KDUMP_FAIL_CMD="echo 'makedumpfile FAILED.'; /bin/bash; reboot -f"
# KDUMP_DUMP_DMESG - This variable controls if the dmesg buffer is dumped.
#     If unset or set to 1, the dmesg buffer is dumped. If set to 0, the dmesg
#     buffer is not dumped.
KDUMP_COREDIR="/var/crash"
#KDUMP_FAIL_CMD="reboot -f"
#KDUMP_DUMP_DMESG=
# KDUMP_NUM_DUMPS - This variable controls how many dump files are kept on
#     the machine to prevent running out of disk space. If set to 0 or unset,
#     the variable is ignored and no dump files are automatically purged.
KDUMP_COREDIR="/var/crash"
#KDUMP_FAIL_CMD="reboot -f"
#KDUMP_DUMP_DMESG=
#KDUMP_NUM_DUMPS=


# ---------------------------------------------------------------------------
"/etc/default/kdump-tools" [readonly] 104L, 4602C  

此时可以在/boot/grub下grub.config中的系统启动参数看到:

3、reboot

4、查看内核启动命令

zyg@zyg:~$ cat /proc/cmdline 
BOOT_IMAGE=/vmlinuz-5.4.0-60-generic root=/dev/mapper/ubuntu--vg-ubuntu--lv ro maybe-ubiquity crashkernel=512M-:192M

5、测试生成vmcore,手动触发系统崩溃

zyg@zyg:~$ su - root
Password: 
root@zyg:~# echo c > /proc/sysrq-trigger 

6、下载vmlinux

可以从这里Index of /pool/main/l/linux下载对应版本的,下载完成后dpkg -i来安装。

安装完成后,可以在/usr/lib/debug/目录下找到,vmlinux位置在/usr/lib/debug/boot/vmlinux-4.15.0-112-generic。

  • 2
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
要在Ubuntu 20.04启用网卡,可以按照以下步骤进行操作: 1. 打开终端,使用以下命令编辑网络配置文件: ``` sudo vim /etc/netplan/00-installer-config.yaml ``` 2. 在配置文件中,找到以太网接口的部分,例如`enp0s3`,根据需要进行修改。可以使用静态IP或DHCP,具体取决于你的网络设置。 - 如果要使用静态IP,请将配置修改为: ``` network: version: 2 ethernets: enp0s3: dhcp4: no addresses: \[192.168.1.10/24\] gateway4: 192.168.1.1 nameservers: addresses: \[192.168.1.1, 114.114.114.114\] ``` - 如果要使用DHCP,请将配置修改为: ``` network: version: 2 ethernets: enp0s3: dhcp4: yes ``` 3. 保存并关闭文件。 4. 使用以下命令应用新的网络配置: ``` sudo netplan apply ``` 这样,你就可以在Ubuntu 20.04启用网卡了。请根据你的网络需求选择适当的配置选项。\[1\]\[2\]\[3\] #### 引用[.reference_title] - *1* *3* [Ubuntu Server 20.04 网卡启动及配置](https://blog.csdn.net/u014129103/article/details/127927064)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down28v1,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [解决Ubuntu20.04网络配置的问题](https://blog.csdn.net/m0_53876797/article/details/124849115)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down28v1,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值