Linux kernelの勉強用にGCPのVMでlive crashしようとしたけど、出来なかった顛末。
crashコマンドのインストール
$ sudo apt-get install crash
デバッグカーネルのインストール
GCP用のデバッグカーネルは下記で発見。ここから自分が使っているカーネル用のパッケージをダウンロード。
$ uname -a
Linux instance-1 4.13.0-1017-gcp #21-Ubuntu SMP Thu May 17 14:45:07 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
$ wget http://launchpadlibrarian.net/370721710/linux-image-4.13.0-1017-gcp-dbgsym_4.13.0-1017.21_amd64.ddeb
$ sudo dpkg -i linux-image-4.13.0-1017-gcp-dbgsym_4.13.0-1017.21_amd64.ddeb
Run crash!(失敗)
いざ、crash実行!
$ dpkg -L linux-image-4.13.0-1017-gcp-dbgsym
...
/usr/lib/debug/boot/vmlinux-4.13.0-1017-gcp
...
$ sudo crash /usr/lib/debug/boot/vmlinux-4.13.0-1017-gcp
crash 7.1.4
Copyright (C) 2002-2015 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.
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 [974MB]: patching 96537 gdb minimal_symbol values
crash: read error: kernel virtual address: ffffffffbf048a90 type: "page_offset_base"
crash: this kernel may be configured with CONFIG_STRICT_DEVMEM, which
renders /dev/mem unusable as a live memory source.
crash: trying /proc/kcore as an alternative to /dev/mem
crash: seek error: kernel virtual address: ffffffffbf048a90 type: "page_offset_base"
/proc/kcoreを使えという事なので、Let's try!
$ crash /usr/lib/debug/boot/vmlinux-4.13.0-1017-gcp /proc/kcore
crash 7.1.4
Copyright (C) 2002-2015 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.
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 [974MB]: patching 96537 gdb minimal_symbol values
crash: seek error: kernel virtual address: ffffffffbf048a90 type: "page_offset_base"
無念・・・。crashの最新版ではFixされている可能性があるのかもしれないが・・・