diff --git a/test/shell/writecache.sh b/test/shell/writecache.sh index ce77cfeff..42c864a9b 100644 --- a/test/shell/writecache.sh +++ b/test/shell/writecache.sh @@ -48,7 +48,7 @@ cp pattern1 $mount_dir/pattern1 umount $mount_dir lvchange -an $vg/$lv1 -lvconvert --type writecache --cachepool $lv2 $vg/$lv1 +lvconvert --yes --type writecache --cachepool $lv2 $vg/$lv1 check lv_field $vg/$lv1 segtype writecache @@ -90,7 +90,7 @@ lvchange -an $vg/$lv2 # test2: create fs on LV after writecache is attached -lvconvert --type writecache --cachepool $lv2 $vg/$lv1 +lvconvert --yes --type writecache --cachepool $lv2 $vg/$lv1 check lv_field $vg/$lv1 segtype writecache diff --git a/tools/lvconvert.c b/tools/lvconvert.c index 3ba7f5b02..2c6384e76 100644 --- a/tools/lvconvert.c +++ b/tools/lvconvert.c @@ -5498,6 +5498,12 @@ static int _lvconvert_writecache_attach_single(struct cmd_context *cmd, return 0; } + if (!arg_is_set(cmd, yes_ARG) && + yes_no_prompt("Erase all existing data on %s? [y/n]: ", display_lvname(lv_fast)) == 'n') { + log_error("Conversion aborted."); + return 0; + } + /* Ensure the two LVs are not active elsewhere. */ if (!lockd_lv(cmd, lv, "ex", 0)) goto_bad;