<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Kdump &#8211; richliu&#039;s blog</title>
	<atom:link href="https://blog.richliu.com/tag/kdump/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.richliu.com</link>
	<description>Linux, 工作, 生活, 家人</description>
	<lastBuildDate>Mon, 26 Aug 2019 08:35:02 +0000</lastBuildDate>
	<language>zh-TW</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.6.2</generator>
	<item>
		<title>Kdump in ubuntu 18.04 ARM64</title>
		<link>https://blog.richliu.com/2019/07/16/4024/kdump-in-ubuntu-18-04-arm64/</link>
					<comments>https://blog.richliu.com/2019/07/16/4024/kdump-in-ubuntu-18-04-arm64/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Tue, 16 Jul 2019 03:55:16 +0000</pubDate>
				<category><![CDATA[ARM]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[arm64]]></category>
		<category><![CDATA[Kdump]]></category>
		<category><![CDATA[qemu]]></category>
		<guid isPermaLink="false">https://blog.richliu.com/?p=4024</guid>

					<description><![CDATA[<p>kdump is very good tool to debug complex system like cl [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2019/07/16/4024/kdump-in-ubuntu-18-04-arm64/">Kdump in ubuntu 18.04 ARM64</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p><br /> kdump is very good tool to debug complex system like cloud data center, it can easy to save kernel status when crash.  <br />Running kdump in ARM64 just like running in x86, but I met a strange problem on ARM64 platform.<br /><br />The kernel version is HWE kernel, current version is 4.18.0-25, mihbt be encounter those problems </p>



<span id="more-4024"></span>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p>$ crash /usr/lib/debug/boot/vmlinux-4.18.0-25-generic 201907111618/dump.201907111618</p><p>crash: cannot determine page size</p></blockquote>



<p>or (after add pagesize parameter )</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p>$ crash /usr/lib/debug/boot/vmlinux-4.18.0-25-generic 201907111618/dump.201907111618 -p 65536</p><p>please wait… (gathering module symbol data)<br /> WARNING: cannot access vmalloc&#8217;d module memory<br /> please wait… (gathering task table data)<br /> WARNING: duplicate idle tasks?<br /> please wait… (determining panic task)<br /> crash: invalid kernel virtual address: ffff0000100d0000  type: &#8220;64-bit KVADDR&#8221;</p></blockquote>



<p>If you have problem like this, please update your Ubuntu crash version. <br />In my opinion, Ubuntu 18.04&#8217;s kdump crash only for kernel 4.15, not for HWE kernel or above. <br /><br />In here, suggest to use HWE kernel or later for more hardware compatibility <br /><br />download latest crash and compile it</p>



<pre class="wp-block-preformatted">vim /etc/apt/source.list
# removed all "#" before # deb-src
apt update
apt-get build-dep linux-crashdump
git clone https://github.com/crash-utility/crash.git
cd crash
make</pre>



<p>and it can assign absolutely path to run new version crash, ex: </p>



<pre class="wp-block-preformatted">/root/crash/crash /usr/lib/debug/boot/vmlinux-5.0.0-20-generic 201907171611/dump.201907171611</pre>



<h2 class="wp-block-heading">Prepare QEMU Image and Run It</h2>



<p>Use ubuntu cloud image as a QEMU Image would be fast and easy, it can download Ubuntu 18.04 cloud image first</p>



<pre class="wp-block-preformatted">wget https://cloud-images.ubuntu.com/bionic/current/bionic-server-cloudimg-arm64.img</pre>



<p>It also can download from local mirror site, like Taiwan mirror server</p>



<pre class="wp-block-preformatted">wget http://ftp.yzu.edu.tw/Linux/ubuntu-cloud-images/bionic/current/bionic-server-cloudimg-arm64.img</pre>



<p>After finished download job, it needs to change cloud image default password for login. <br />please refer another article <a rel="noreferrer noopener" aria-label="Change Ubuntu Cloud Image Password (opens in a new tab)" href="https://blog.richliu.com/2017/08/31/2165/change-ubuntu-cloud-image-password" target="_blank">Change Ubuntu Cloud Image Password</a>. to change it. <br /></p>



<h3 class="wp-block-heading">Run QEMU With Cloud Image</h3>



<p>Before run QEMU command, it needs to install necessary packages </p>



<pre class="wp-block-preformatted">sudo apt install -y qemu-efi qemu bridge-utils</pre>



<p>Write bridge devices into qemu</p>



<pre class="wp-block-preformatted">mkdir -p /etc/qemu
echo "allow br0" &gt; /etc/qemu/bridge.conf
echo "allow virbr0" &gt;&gt; /etc/qemu/bridge.conf</pre>



<p>Create UEFI Bios image and flush for QEMU</p>



<pre class="wp-block-preformatted">dd if=/dev/zero of=flash0.img bs=1M count=64
dd if=/usr/share/qemu-efi/QEMU_EFI.fd of=flash0.img conv=notrunc
dd if=/dev/zero of=flash1.img bs=1M count=64</pre>



<p>Configure you major LAN as bridge device, it can modify setup below to fit current network environment </p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p>ORIGNIC=enP6p1s0<br /> ip addr flush $ORIGNIC <br /> brctl addbr br0<br /> brctl addif br0  $ORIGNIC  <br /> ifconfig br0 up<br /> ifconfig br0 192.168.1.100 netmask 255.255.255.0<br /> route add default gw 192.168.1.1<br /> echo nameserver 8.8.8.8 &gt;&gt; /etc/resolv.conf</p><cite><br /></cite></blockquote>



<p>Save text below into a  shell file and run it. </p>



<pre class="wp-block-preformatted">  
SERVERFILE=bionic-server-cloudimg-arm64.img

 sudo qemu-system-aarch64 -name kdump-vm \
         -machine virt,gic_version=3,accel=kvm,usb=off \
         -cpu host -m 8192 \
         -smp 8,sockets=1,cores=8,threads=1 \
         -nographic -nodefaults \
         -drive if=pflash,format=raw,readonly,file=flash0.img \
         -drive if=pflash,format=raw,file=flash1.img \
         -drive file=$SERVERFILE,if=none,id=disk1  \
         -device virtio-blk-device,scsi=off,drive=disk1,id=virtio-disk1,bootindex=1 \
         -netdev tap,id=net0,ifname=tap0 \
         -device virtio-net-device,netdev=net0 \
         -serial telnet::9001,server,nowait > vm_log.txt 2>&amp;1 &amp;
 sleep 5
 brctl addif br0 tap0 </pre>



<p>it can use command &#8220;telnet localhost 9001&#8221; to login qemu image . <br />if failed, please check vm_log.txt for reason. <br /><br />if there is blank screen on VM, please check whether copy right qemu-efi into flash0.img. </p>



<h2 class="wp-block-heading">Running Kdump in VM</h2>



<p>It can install openssh-server in VM, thus, it would be more easy to run command remotely. especially, if used telnet, vim usually cannot reflect right terminal window size and cannot wrap word correctly. <br /><br /> Install kdump (only for ARM64 QEMU, if used HEW kernel, it needs to download latest version linux-crashdump)</p>



<pre class="wp-block-preformatted">sudo apt install linux-crashdump</pre>



<p>More information about install kdump, please refer to this article <a rel="noreferrer noopener" aria-label="Kernel Crash Dump (opens in a new tab)" href="https://help.ubuntu.com/lts/serverguide/kernel-crash-dump.html" target="_blank">Kernel Crash Dump</a><br /><br />I would suggest to increase kdump ramdisk size to 512M, not used ubuntu linux-crashdump default size. edit /etc/default/grub.d/kdump-tools.cfg and find your RAM size, change following parameter to 512M, ex: my VM memory size is 8GB, so, I modify 4G-32G paramete to 4G-32G:512M<br /></p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p>GRUB_CMDLINE_LINUX_DEFAULT=&#8221;$GRUB_CMDLINE_LINUX_DEFAULT crashkernel=2G-4G:320M,4G-32G:512M,32G-64G:1024M,64G-128G:2048M,128G-:4096M&#8221;</p></blockquote>



<p>After update kernel parameter, update grub to make sure it will get new parameter on boot</p>



<pre class="wp-block-preformatted">update-grub2</pre>



<h3 class="wp-block-heading">Install Kernel Debug Symbol</h3>



<p>Install GPG Key</p>



<pre class="wp-block-preformatted">sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C8CAB6595FDFF622</pre>



<p>Add repository config</p>



<pre class="wp-block-preformatted">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</pre>



<p>Update packages and install symbol. (ref <a href="https://hadibrais.wordpress.com/2017/03/13/installing-ubuntu-kernel-debugging-symbols/" target="_blank" rel="noreferrer noopener" aria-label="Installing Ubuntu Kernel Debugging&nbsp;Symbols (opens in a new tab)">Installing Ubuntu Kernel Debugging&nbsp;Symbols</a>)</p>



</pre><pre class="wp-block-preformatted">sudo apt-get update
sudo apt-get install linux-image-$(uname -r)-dbgsym</pre>



<h2 class="wp-block-heading">Trigger Kdump</h2>



<p>it can used command </p>



<pre class="wp-block-preformatted">kdump-config show </pre>



<p>to check current kdump status. </p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p>$ kdump-config show<br /> DUMP_MODE:        kdump<br /> USE_KDUMP:        1<br /> KDUMP_SYSCTL:     kernel.panic_on_oops=1<br /> KDUMP_COREDIR:    /var/crash<br /> crashkernel addr: 0xdfe00000<br />    /var/lib/kdump/vmlinuz: symbolic link to /boot/vmlinuz-4.15.0-54-generic<br /> kdump initrd:<br />    /var/lib/kdump/initrd.img: symbolic link to /var/lib/kdump/initrd.img-4.15.0-54-generic<br /><strong> current state:    ready to kdump</strong><br /> kexec command:<br />   /sbin/kexec -p &#8211;command-line=&#8221;BOOT_IMAGE=/boot/vmlinuz-4.15.0-54-generic root=UUID=6242429e-2876-4d52-a590-99654a6a91ac ro quiet splash vt.handoff=1 nr_cpus=1 systemd.unit=kdump-tools-dump.service&#8221; &#8211;initrd=/var/lib/kdump/initrd.img /var/lib/kdump/vmlinuz</p></blockquote>



<p>if evenything is ok, it should have state: ready to kdump .<br /><br /></p>



<h3 class="wp-block-heading">Trigger Kdump</h3>



<p>it can easy to trigger Kdump via sysrq. I will suggest to trigger sysrq on telnet. it will show dump message and reboot message.  more easy to know it get right result. </p>



<pre class="wp-block-preformatted">echo 1 &gt; /proc/sys/kernel/sysrq
echo c &gt; /proc/sysrq-trigger</pre>



<p>First command to configure sysrq to accept all trigger. <br />Second command is to trigger kernel crash </p>



<p>$ echo c &gt; /proc/sysrq-trigger<br /> [   31.855103] sysrq: SysRq : Trigger a crash<br /> [   31.861713] Internal error: Accessing user space memory outside uaccess.h routines: 96000044 [#1] SMP<br /> [   31.869136] Modules linked in: nls_iso8859_1 sch_fq_codel ib_iser rdma_cm iw_cm ib_cm ib_core iscsi_tcp libiscsi_tcp libiscsi scsi_transport_iscsi ip_tables x_tables autofs4 btrfs zstd_compress raid10 raid456 async_raid6_recov async_memcpy async_pq async_xor async_tx xor raid6_pq libcrc32c raid1 raid0 multipath linear aes_ce_blk aes_ce_cipher crc32_ce<br /> crct10dif_ce ghash_ce sha2_ce sha256_arm64 sha1_ce virtio_net virtio_blk aes_neon_bs aes_neon_blk crypto_simd cryptd aes_arm64<br /> [   31.879776] CPU: 1 PID: 1385 Comm: bash Not tainted 4.15.0-54-generic #58-Ubuntu<br /> [   31.882430] Hardware name: QEMU KVM Virtual Machine, BIOS 0.0.0 02/06/2015<br /> [   31.884892] pstate: 00400005 (nzcv daif +PAN -UAO)<br /> [   31.886641] pc : sysrq_handle_crash+0x24/0x30<br /> [   31.888198] lr : __handle_sysrq+0xbc/0x1c0<br /> [   31.889627] sp : ffff00000e513d50<br /> [   31.890835] x29: ffff00000e513d50 x28: ffff8001f2e93c00<br /> [   31.892723] x27: ffff000008b32000 x26: 0000000000000040<br /> [   31.894639] x25: 0000000000000124 x24: ffff0000095ee000<br /> [   31.896524] x23: 0000000000000004 x22: 0000000000000002<br /> [   31.898433] x21: 0000000000000063 x20: ffff000009550000<br /> [   31.900309] x19: ffff0000095ee4e0 x18: ffffffffffffffff<br /> [   31.902229] x17: 0000000000000000 x16: 0000000000000000<br /> [   31.904127] x15: ffff000009528c08 x14: ffff0000896d687f<br /> [   31.906046] x13: ffff0000096d688d x12: ffff00000954f000<br /> [   31.907954] x11: ffff000009529660 x10: ffff000008708540<br /> [   31.909848] x9 : 00000000ffffffd0 x8 : 0000000000000017<br /> [   31.911801] x7 : 6767697254203a20 x6 : ffff8001ffdc82e8<br /> [   31.913655] x5 : ffff8001ffdc82e8 x4 : 0000000000000000<br /> [   31.915569] x3 : ffff8001ffdd06c8 x2 : 068be67f3165eb00<br /> [   31.917430] x1 : 0000000000000000 x0 : 0000000000000001<br /> [   31.919312] Process bash (pid: 1385, stack limit = 0x        (ptrval))<br /> [   31.921599] Call trace:<br /> [   31.922506]  sysrq_handle_crash+0x24/0x30<br /> [   31.923964]  __handle_sysrq+0xbc/0x1c0<br /> [   31.925311]  write_sysrq_trigger+0xd8/0x120<br /> [   31.926851]  proc_reg_write+0x80/0xc0<br /> [   31.928178]  __vfs_write+0x48/0x80<br /> [   31.929399]  vfs_write+0xac/0x1b0<br /> [   31.930618]  SyS_write+0x6c/0xd8<br /> [   31.931777]  el0_svc_naked+0x30/0x34<br /> [   31.933062] Code: 52800020 b90ca020 d5033e9f d2800001 (39000020)<br /> [   31.935269] SMP: stopping secondary CPUs<br /> [   31.937745] Starting crashdump kernel…<br /> [   31.939108] Bye!</p>



<p>After kdump save current status and reboot , it will save crash log on /var/crash, run crash command below, it can see some output </p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p>$ crash &#8211;mod /usr/lib/debug/lib/modules/4.15.0-54-generic/ /usr/lib/debug/boot/vmlinux-4.15.0-<br /> 54-generic 201907150556/dump.201907150556<br /> crash 7.2.1<br /> Copyright (C) 2002-2017  Red Hat, Inc.<br /> Copyright (C) 2004, 2005, 2006, 2010  IBM Corporation<br /> Copyright (C) 1999-2006  Hewlett-Packard Co<br /> Copyright (C) 2005, 2006, 2011, 2012  Fujitsu Limited<br /> Copyright (C) 2006, 2007  VA Linux Systems Japan K.K.<br /> Copyright (C) 2005, 2011  NEC Corporation<br /> Copyright (C) 1999, 2002, 2007  Silicon Graphics, Inc.<br /> Copyright (C) 1999, 2000, 2001, 2002  Mission Critical Linux, Inc.<br /> This program is free software, covered by the GNU General Public License,<br /> and you are welcome to change it and/or distribute copies of it under<br /> certain conditions.  Enter &#8220;help copying&#8221; to see the conditions.<br /> This program has absolutely no warranty.  Enter &#8220;help warranty&#8221; for details.<br /> GNU gdb (GDB) 7.6<br /> Copyright (C) 2013 Free Software Foundation, Inc.<br /> License GPLv3+: GNU GPL version 3 or later <a href="http://gnu.org/licenses/gpl.html" target="_blank" rel="noopener">http://gnu.org/licenses/gpl.html</a><br /> This is free software: you are free to change and redistribute it.<br /> There is NO WARRANTY, to the extent permitted by law.  Type &#8220;show copying&#8221;<br /> and &#8220;show warranty&#8221; for details.<br /> This GDB was configured as &#8220;aarch64-unknown-linux-gnu&#8221;…<br /> <code>  KERNEL: /usr/lib/debug/boot/vmlinux-4.15.0-54-generic DUMPFILE: 201907150556/dump.201907150556  [PARTIAL DUMP]     CPUS: 12     DATE: Mon Jul 15 05:56:07 2019   UPTIME: 2135039823346 days, 00:15:35</code><br /> LOAD AVERAGE: 0.41, 0.32, 0.13<br />        TASKS: 202<br />     NODENAME: ubuntu<br />      RELEASE: 4.15.0-54-generic<br />      VERSION: #58-Ubuntu SMP Mon Jun 24 10:56:40 UTC 2019<br />      MACHINE: aarch64  (unknown Mhz)<br />       MEMORY: 8 GB<br />        PANIC: &#8220;sysrq: SysRq : Trigger a crash&#8221;<br />          PID: 1444<br />      COMMAND: &#8220;bash&#8221;<br />         TASK: ffff8001f019ad00  [THREAD_INFO: ffff8001f019ad00]<br />          CPU: 1<br />        STATE: TASK_RUNNING (SYSRQ)</p></blockquote>



<p>Next step, more how to use crash information, please refer to article <a href="https://www.dedoimedo.com/computers/crash-analyze.html" target="_blank" rel="noreferrer noopener" aria-label="Analyzing Linux kernel crash dumps with crash - The one tutorial that has it all (opens in a new tab)">Analyzing Linux kernel crash dumps with crash &#8211; The one tutorial that has it all</a></p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2019/07/16/4024/kdump-in-ubuntu-18-04-arm64/">Kdump in ubuntu 18.04 ARM64</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.richliu.com/2019/07/16/4024/kdump-in-ubuntu-18-04-arm64/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>ARM64 Kdump cannot allocate crashkernel</title>
		<link>https://blog.richliu.com/2019/07/11/4004/arm64-kdump-cannot-allocate-crashkernel/</link>
					<comments>https://blog.richliu.com/2019/07/11/4004/arm64-kdump-cannot-allocate-crashkernel/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Thu, 11 Jul 2019 03:19:15 +0000</pubDate>
				<category><![CDATA[ARM]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[arm64]]></category>
		<category><![CDATA[Kdump]]></category>
		<category><![CDATA[ubuntu]]></category>
		<guid isPermaLink="false">https://blog.richliu.com/?p=4004</guid>

					<description><![CDATA[<p>In ARM64 server and installed memory around 128G, ubunt [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2019/07/11/4004/arm64-kdump-cannot-allocate-crashkernel/">ARM64 Kdump cannot allocate crashkernel</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>In ARM64 server and installed memory around 128G, ubuntu default /etc/default/grub.d/kdump-tools.cfg default configuration might cause kdump allocate memory failed. error message as below </p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p>  [ 0.000000] cannot allocate crashkernel (size:0x80000000)<br />[ 0.000000] Kernel command line: BOOT_IMAGE=/boot/vmlinuz-4.18.0-25-generic root=UUID=ee8be10d-d649-425d-a807-640751836186 ro console=tty0 crashkernel=2G-4G:320M,4G-32G:512M,32G-64G:1024M,64G-128G:2048M,128G-:4096M</p></blockquote>



<span id="more-4004"></span>



<p>reserve memory is for RAM disk. root cause might be system cannot allocate enough memory for crash kernel. </p>



<p>Reduce allocate memory size will work </p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p>dmesg | grep crash<br /> [    0.000000] crashkernel reserved: 0x00000000bfe00000 &#8211; 0x00000000ffe00000 (1024 MB)<br /> [    0.000000] Kernel command line: BOOT_IMAGE=/boot/vmlinuz-4.18.0-25-generic root=UUID=ee8be10d-d649-425d-a807-640751836186 ro console=tty0 crashkernel=2G-4G:320M,4G-32G:512M,32G-64G:1024M,64G-128G:1024M,high,128G-:16384M</p></blockquote>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2019/07/11/4004/arm64-kdump-cannot-allocate-crashkernel/">ARM64 Kdump cannot allocate crashkernel</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.richliu.com/2019/07/11/4004/arm64-kdump-cannot-allocate-crashkernel/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
