Linux

commands

Linux の操作で調査に苦労した手法を記録してあります。

lldb

デバッグについて。clangではcoreファイルの解析にldbを使います。 http://lldb.llvm.org/lldb-gdb.html
sudo apt install lldb
また、Coreファイルを出力する設定を以下のように行います。
sudo ulimit -c unlimited

fdisk

fdisk -l check all partition on this PC
https://askubuntu.com/questions/167015/how-to-find-out-which-partition-is-ubuntu-installed-on

grub

sudo grub-mkconfig -o /boot/grub/grub.cfg
https://unix.stackexchange.com/questions/62733/how-to-correctly-set-up-the-right-grub-2-default-menu-entry

次のコマンドによりentryを探し、

$ grep "menuentry " /boot/grub/grub.cfg
menuentry 'Ubuntu' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-f09a8e37-ea35-433b-8e1d-4cb0cf5b9b64' {
        menuentry 'Ubuntu, with Linux 4.11.0-kfd-compute-rocm-rel-1.6-180' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.11.0-kfd-compute-rocm-rel-1.6-180-advanced-f09a8e37-ea35-433b-8e1d-4cb0cf5b9b64' {
        menuentry 'Ubuntu, with Linux 4.11.0-kfd-compute-rocm-rel-1.6-180 (upstart)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.11.0-kfd-compute-rocm-rel-1.6-180-init-upstart-f09a8e37-ea35-433b-8e1d-4cb0cf5b9b64' {
        menuentry 'Ubuntu, with Linux 4.11.0-kfd-compute-rocm-rel-1.6-180 (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.11.0-kfd-compute-rocm-rel-1.6-180-recovery-f09a8e37-ea35-433b-8e1d-4cb0cf5b9b64' {
        menuentry 'Ubuntu, with Linux 4.10.0-42-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.10.0-42-generic-advanced-f09a8e37-ea35-433b-8e1d-4cb0cf5b9b64' {
        menuentry 'Ubuntu, with Linux 4.10.0-42-generic (upstart)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.10.0-42-generic-init-upstart-f09a8e37-ea35-433b-8e1d-4cb0cf5b9b64' {
        menuentry 'Ubuntu, with Linux 4.10.0-42-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.10.0-42-generic-recovery-f09a8e37-ea35-433b-8e1d-4cb0cf5b9b64' {
        menuentry 'Ubuntu, with Linux 4.10.0-40-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.10.0-40-generic-advanced-f09a8e37-ea35-433b-8e1d-4cb0cf5b9b64' {
        menuentry 'Ubuntu, with Linux 4.10.0-40-generic (upstart)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.10.0-40-generic-init-upstart-f09a8e37-ea35-433b-8e1d-4cb0cf5b9b64' {
        menuentry 'Ubuntu, with Linux 4.10.0-40-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.10.0-40-generic-recovery-f09a8e37-ea35-433b-8e1d-4cb0cf5b9b64' {
        menuentry 'Ubuntu, with Linux 4.10.0-28-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.10.0-28-generic-advanced-f09a8e37-ea35-433b-8e1d-4cb0cf5b9b64' {
        menuentry 'Ubuntu, with Linux 4.10.0-28-generic (upstart)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.10.0-28-generic-init-upstart-f09a8e37-ea35-433b-8e1d-4cb0cf5b9b64' {
        menuentry 'Ubuntu, with Linux 4.10.0-28-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.10.0-28-generic-recovery-f09a8e37-ea35-433b-8e1d-4cb0cf5b9b64' {
menuentry 'Memory test (memtest86+)' {
menuentry 'Memory test (memtest86+, serial console 115200)' {
menuentry 'Ubuntu 16.04.3 LTS (16.04) (on /dev/sdb1)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-simple-cbb4f33f-18ae-4ced-bafb-44820338fe54' {
        menuentry 'Ubuntu (on /dev/sdb1)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/vmlinuz-4.10.0-40-generic--cbb4f33f-18ae-4ced-bafb-44820338fe54' {
        menuentry 'Ubuntu, with Linux 4.10.0-40-generic (on /dev/sdb1)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/vmlinuz-4.10.0-40-generic--cbb4f33f-18ae-4ced-bafb-44820338fe54' {
        menuentry 'Ubuntu, with Linux 4.10.0-40-generic (upstart) (on /dev/sdb1)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/vmlinuz-4.10.0-40-generic--cbb4f33f-18ae-4ced-bafb-44820338fe54' {
        menuentry 'Ubuntu, with Linux 4.10.0-40-generic (recovery mode) (on /dev/sdb1)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/vmlinuz-4.10.0-40-generic-root=UUID=cbb4f33f-18ae-4ced-bafb-44820338fe54 ro recovery nomodeset-cbb4f33f-18ae-4ced-bafb-44820338fe54' {
        menuentry 'Ubuntu, with Linux 4.10.0-28-generic (on /dev/sdb1)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/vmlinuz-4.10.0-28-generic--cbb4f33f-18ae-4ced-bafb-44820338fe54' {
        menuentry 'Ubuntu, with Linux 4.10.0-28-generic (upstart) (on /dev/sdb1)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/vmlinuz-4.10.0-28-generic--cbb4f33f-18ae-4ced-bafb-44820338fe54' {
        menuentry 'Ubuntu, with Linux 4.10.0-28-generic (recovery mode) (on /dev/sdb1)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/vmlinuz-4.10.0-28-generic-root=UUID=cbb4f33f-18ae-4ced-bafb-44820338fe54 ro recovery nomodeset-cbb4f33f-18ae-4ced-bafb-44820338fe54' {

例えば次のように設定すると次回起動時のkernelを選べる。

sudo grub-reboot 'Ubuntu 16.04.3 LTS (16.04) (on /dev/sdb1)'

入れ子になった項目を選びたい場合は以下のようにする。

sudo grub-reboot 'Ubuntu 16.04.3 LTS (16.04) (on /dev/sdb1) > Ubuntu, with Linux 4.10.0-40-generic (on /dev/sdb1)'

数字により選ぶことはわかりづらいのでお勧めしません。

dd

how to clone a disk.
https://wiki.archlinux.org/index.php/disk_cloning