From 17202cfd9f2a677c36be744d65f7e90efbf854c0 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Fri, 2 Aug 2019 14:42:06 +0200 Subject: [PATCH 1/7] mxgrub: Log to ttyS0 as well Add "console=ttyS0,115200n8" to the kernel command line to get kernel ring buffer logging to both serials. --- mxgrub/mxgrub | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mxgrub/mxgrub b/mxgrub/mxgrub index b0f81e1..fdeb27f 100755 --- a/mxgrub/mxgrub +++ b/mxgrub/mxgrub @@ -246,7 +246,7 @@ sub update_grub_cfg { for my $label (@MARIUX) { my $image=label_to_image($label); - $kernellist.="\tmenuentry \"$label\" --unrestricted { save_env chosen ; linux /boot/$image crashkernel=256M root=LABEL=root ro console=ttyS1,115200n8 console=tty0 init=/bin/systemd audit=0 ; initrd /boot/grub/initramfs.igz }\n"; + $kernellist.="\tmenuentry \"$label\" --unrestricted { save_env chosen ; linux /boot/$image crashkernel=256M root=LABEL=root ro console=ttyS0,115200n8 console=ttyS1,115200n8 console=tty0 init=/bin/systemd audit=0 ; initrd /boot/grub/initramfs.igz }\n"; } my $GRUB_CFG_NEW=<<"EOF"; @@ -266,7 +266,7 @@ if [ -e /etc/local/USB.usb ]; then menuentry "mariuxUSB" --unrestricted { save_env chosen ; linux /boot/bzImage.x86_64 crashkernel=256M root=LABEL=rootusb ro init=/bin/systemd audit=0 ; initrd /boot/grub/initramfs.igz } else -menuentry "$MARIUX_DEFAULT" --unrestricted { set chosen="$submenu>$MARIUX_DEFAULT" ; save_env chosen ; linux /boot/bzImage.x86_64 crashkernel=256M root=LABEL=root ro console=ttyS1,115200n8 console=tty0 init=/bin/systemd audit=0 ; initrd /boot/grub/initramfs.igz } +menuentry "$MARIUX_DEFAULT" --unrestricted { set chosen="$submenu>$MARIUX_DEFAULT" ; save_env chosen ; linux /boot/bzImage.x86_64 crashkernel=256M root=LABEL=root ro console=ttyS0,115200n8 console=ttyS1,115200n8 console=tty0 init=/bin/systemd audit=0 ; initrd /boot/grub/initramfs.igz } submenu "$submenu" --unrestricted { $kernellist From cc211e0df97c8bdc8cddf751437942899125387d Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Fri, 2 Aug 2019 14:48:12 +0200 Subject: [PATCH 2/7] mxgrub: Deduplicate kernel parameter list --- mxgrub/mxgrub | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mxgrub/mxgrub b/mxgrub/mxgrub index fdeb27f..4200bbd 100755 --- a/mxgrub/mxgrub +++ b/mxgrub/mxgrub @@ -239,6 +239,8 @@ sub scan_mariux { } } +our $KERNEL_PARAMETER="ro crashkernel=256M console=ttyS0,115200n8 console=ttyS1,115200n8 console=tty0 init=/bin/systemd audit=0"; + sub update_grub_cfg { my $kernellist=''; @@ -263,10 +265,10 @@ insmod all_video if [ -e /etc/local/USB.usb ]; then set default="mariuxUSB" - menuentry "mariuxUSB" --unrestricted { save_env chosen ; linux /boot/bzImage.x86_64 crashkernel=256M root=LABEL=rootusb ro init=/bin/systemd audit=0 ; initrd /boot/grub/initramfs.igz } + menuentry "mariuxUSB" --unrestricted { save_env chosen ; linux /boot/bzImage.x86_64 root=LABEL=rootusb $KERNEL_PARAMETER ; initrd /boot/grub/initramfs.igz } else -menuentry "$MARIUX_DEFAULT" --unrestricted { set chosen="$submenu>$MARIUX_DEFAULT" ; save_env chosen ; linux /boot/bzImage.x86_64 crashkernel=256M root=LABEL=root ro console=ttyS0,115200n8 console=ttyS1,115200n8 console=tty0 init=/bin/systemd audit=0 ; initrd /boot/grub/initramfs.igz } +menuentry "$MARIUX_DEFAULT" --unrestricted { set chosen="$submenu>$MARIUX_DEFAULT" ; save_env chosen ; linux /boot/bzImage.x86_64 root=LABEL=root $KERNEL_PARAMETER ; initrd /boot/grub/initramfs.igz } submenu "$submenu" --unrestricted { $kernellist From 31c784c15ab48e828ffb2a3c75071c4e73c47d11 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Fri, 2 Aug 2019 14:51:17 +0200 Subject: [PATCH 3/7] mxgrub: Do not use old command line on reboot When we use `mxgrub --reboot` we don't want to reuse the previous kernel command line. Generate a new command line for kexec. This way, changes we make to $KERNEL_PARAMETER in this script can be activated by `mxgrub --reboot` as well. --- mxgrub/mxgrub | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mxgrub/mxgrub b/mxgrub/mxgrub index 4200bbd..d88b79c 100755 --- a/mxgrub/mxgrub +++ b/mxgrub/mxgrub @@ -360,7 +360,7 @@ sub cmd_reboot { my $image=label_to_image($chosen); -e "/boot/$image" or die "/boot/$image: no such file\n"; sys('sync'); - sys('kexec',"/boot/$image",'--reuse-cmdline','--initrd=/boot/grub/initramfs.igz'); + sys('kexec',"/boot/$image",'--initrd=/boot/grub/initramfs.igz',"--command-line=root=LABEL=root $KERNEL_PARAMETER"); } umask 022; From 91729569c7d44125fa3f5f68ce792df36d2c7261 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Fri, 2 Aug 2019 15:05:05 +0200 Subject: [PATCH 4/7] Import crashkernel.service Import existing crashkernel.service into repository. --- install.sh | 1 + misc_systemd_units/crashkernel.service | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 misc_systemd_units/crashkernel.service diff --git a/install.sh b/install.sh index 1718ab9..58c140c 100755 --- a/install.sh +++ b/install.sh @@ -149,4 +149,5 @@ install_data misc_systemd_units/mxvlan.service "$DESTDIR$systemdunitd mkdir -p "$DESTDIR$usr_prefix/share/applications" install_data applications-defaults/defaults.list "$DESTDIR$usr_prefix/share/applications/defaults.list" install_data misc_etc_files/modprobe.d/nfs_slotlimit.conf "$DESTDIR$sysconfdir/modprobe.d/nfs_slotlimit.conf" +install_data misc_systemd_units/crashkernel.service "$DESTDIR$systemdunitdir/crashkernel.service" exit diff --git a/misc_systemd_units/crashkernel.service b/misc_systemd_units/crashkernel.service new file mode 100644 index 0000000..402ea5a --- /dev/null +++ b/misc_systemd_units/crashkernel.service @@ -0,0 +1,13 @@ +[Unit] +Description=load crashkernel +ConditionPathExists=/boot/bzImage.crash + +[Service] +StandardOutput=kmsg +StandardError=kmsg +Type=oneshot +ExecStart=/usr/sbin/kexec -p /boot/bzImage.crash --initrd=/boot/grub/initramfs.igz "--append=root=LABEL=root ro console=ttyS1,115200n8 console=tty0 irqpoll maxcpus=1 reset_devices CRASH" +RemainAfterExit=yes + +[Install] +WantedBy=basic.target From 7ba29f13d1ad07ec3c2d06c2394e377fc1d5ab6c Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Fri, 2 Aug 2019 15:07:39 +0200 Subject: [PATCH 5/7] crashkernel: Add ttyS0 console Add "console=ttyS0,115200n8" to crashkernel commandline as we did for the regular kernel in mxgrub. Also specifiy full command line here instead of appending to the command line of the crashing kernel to get a better defined state. --- misc_systemd_units/crashkernel.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc_systemd_units/crashkernel.service b/misc_systemd_units/crashkernel.service index 402ea5a..fde443c 100644 --- a/misc_systemd_units/crashkernel.service +++ b/misc_systemd_units/crashkernel.service @@ -6,7 +6,7 @@ ConditionPathExists=/boot/bzImage.crash StandardOutput=kmsg StandardError=kmsg Type=oneshot -ExecStart=/usr/sbin/kexec -p /boot/bzImage.crash --initrd=/boot/grub/initramfs.igz "--append=root=LABEL=root ro console=ttyS1,115200n8 console=tty0 irqpoll maxcpus=1 reset_devices CRASH" +ExecStart=/usr/sbin/kexec -p /boot/bzImage.crash --initrd=/boot/grub/initramfs.igz --command-line="root=LABEL=root ro console=ttyS0,115200n8 console=ttyS1,115200n8 console=tty0 irqpoll maxcpus=1 reset_devices CRASH" RemainAfterExit=yes [Install] From d25a4f4258fb3ac7fd241e2e0c91a466de596139 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Fri, 2 Aug 2019 15:32:34 +0200 Subject: [PATCH 6/7] crashkernel: Add ExecStop Add ExecStop to unload the panic kernel. "systemctl stop crashkernel" can be used to disable the panic reboot and free the memory. "systemctl restart crashkernel" can be used to reload the panic kernel. --- misc_systemd_units/crashkernel.service | 1 + 1 file changed, 1 insertion(+) diff --git a/misc_systemd_units/crashkernel.service b/misc_systemd_units/crashkernel.service index fde443c..61ef8f4 100644 --- a/misc_systemd_units/crashkernel.service +++ b/misc_systemd_units/crashkernel.service @@ -7,6 +7,7 @@ StandardOutput=kmsg StandardError=kmsg Type=oneshot ExecStart=/usr/sbin/kexec -p /boot/bzImage.crash --initrd=/boot/grub/initramfs.igz --command-line="root=LABEL=root ro console=ttyS0,115200n8 console=ttyS1,115200n8 console=tty0 irqpoll maxcpus=1 reset_devices CRASH" +ExecStop=/usr/sbin/kexec -p -u RemainAfterExit=yes [Install] From 13bf77c16a3d8e957bffe0849d9c89811db91a76 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Fri, 2 Aug 2019 15:36:10 +0200 Subject: [PATCH 7/7] crashkernel: Remove dangling whitespace --- misc_systemd_units/crashkernel.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc_systemd_units/crashkernel.service b/misc_systemd_units/crashkernel.service index 61ef8f4..26695c0 100644 --- a/misc_systemd_units/crashkernel.service +++ b/misc_systemd_units/crashkernel.service @@ -1,6 +1,6 @@ [Unit] Description=load crashkernel -ConditionPathExists=/boot/bzImage.crash +ConditionPathExists=/boot/bzImage.crash [Service] StandardOutput=kmsg