From 5b385cbd0ccc3985724c500fb823a722b07f0e8f Mon Sep 17 00:00:00 2001 From: Kenneth Dsouza Date: Wed, 15 Aug 2018 18:44:15 +0530 Subject: [PATCH] kdumpctl: Print warning in case the raw device is formatted and contains filesystem. Currently the kdumpctl script doesn't check if the raw device is formatted which might destroy existing data at the time of dump capture. This patch addresses this issue, by ensuring kdumpctl prints a warning in case it finds the raw device to be formatted. Signed-off-by: Kenneth D'souza Acked-by: Kairui Song --- kdumpctl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kdumpctl b/kdumpctl index e07ec06..ece406f 100755 --- a/kdumpctl +++ b/kdumpctl @@ -786,6 +786,11 @@ save_raw() echo "raw partition $raw_target not found" return 1 } + check_fs=$(lsblk --nodeps -npo FSTYPE $raw_target) + if [[ $(echo $check_fs | wc -w) -ne 0 ]]; then + echo "Warning: Detected '$check_fs' signature on $raw_target, data loss is expected." + return 0 + fi kdump_dir=`grep ^path $KDUMP_CONFIG_FILE | cut -d' ' -f2-` if [ -z "${kdump_dir}" ]; then coredir="/var/crash/`date +"%Y-%m-%d-%H:%M"`"