From 89565289c64aa5323278cf5722c725a58b369af8 Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Tue, 4 Dec 2018 11:09:43 +0800 Subject: [PATCH] kdump-lib-initramfs.sh: using -force option when poweroff If default action is poweroff, we can observe that the machine is rebooted, instead of poweroff. That is due to the following two race processes: systemctl poweroff systemctl reboot -f which is launched by kdump-error-handle.sh. Unfortunately, although both of them are executed in systemd block mode, but due to poweroff will tear down some internal things in systemd, there is no guarantee for the block mode. As we can see the msg "Failed to execute operation: Connection reset by peer", which is thrown by "systemctl reboot -f". poweroff and reboot share most of code, if one fails, then the other should also fails, so it is meaningless to use reboot as the backup of poweroff. Using "systemctl poweroff -f", the sdbus will teared down immediately, which prevent the following "systemctl reboot -f" from executing. Meanwhile, as man systemctl says: -f, --force When used with enable, overwrite any existing conflicting symlinks. When used with halt, poweroff, reboot or kexec, execute the selected operation without shutting down all units. However, all processes will be killed forcibly and all file systems are unmounted or remounted read-only. Hence, replacing the 'poweroff' with 'systemctl poweroff -f' Signed-off-by: Pingfan Liu Acked-by: Kairui Song --- kdump-lib-initramfs.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index c7f874f..f5155a4 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -63,7 +63,7 @@ get_kdump_confs() DEFAULT_ACTION="halt" ;; poweroff) - DEFAULT_ACTION="poweroff" + DEFAULT_ACTION="systemctl poweroff -f" ;; dump_to_rootfs) DEFAULT_ACTION="dump_to_rootfs"