Hi, Kenneth

Not sure if this is a good idea, this will change kdumpctl's behavior and may lead to unexpected kdump service failure.
Maybe it's the user's responsibility to check if the target is ready to be used as raw target.
Better be a warning to let user know currently partition might be lost rather than an error.
And still, this can't prevent kdump destroy a partition table if a device is partitioned.

On Sat, Jul 28, 2018, 08:25 Kenneth Dsouza <kdsouza@redhat.com> wrote:
From: Kenneth D'souza <kdsouza@redhat.com>

Currently the kdumpctl script doesn't check if the raw device is
formatted which might destroy existing data at the time of dump

This patch addresses this issue, by ensuring that the kdumpctl
errors out in case it finds the raw device to be formatted.

Signed-off-by: Kenneth D'souza <kdsouza@redhat.com>
 kdumpctl | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/kdumpctl b/kdumpctl
index 6a01c13..bb4e576 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -779,6 +779,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 "Detected $check_fs signature on $raw_target"
+                return 1
+        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"`"
kexec mailing list -- kexec@lists.fedoraproject.org
To unsubscribe send an email to kexec-leave@lists.fedoraproject.org
Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/kexec@lists.fedoraproject.org/message/2G254ZNE56Y54XDWAKACFKEQA7EDXAWI/