From c21af671d654fa506bc949bba6df8eeb9b1ffdeb Mon Sep 17 00:00:00 2001 From: wanyaoqi <18528551+wanyaoqi@users.noreply.github.com> Date: Mon, 23 Mar 2026 19:01:21 +0800 Subject: [PATCH] fix(host): dd zero to lv wife partitions on lvremove (#24527) --- pkg/hostman/storageman/lvmutils/lvmutils.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/hostman/storageman/lvmutils/lvmutils.go b/pkg/hostman/storageman/lvmutils/lvmutils.go index 8287c8dce0..8042ca5f96 100644 --- a/pkg/hostman/storageman/lvmutils/lvmutils.go +++ b/pkg/hostman/storageman/lvmutils/lvmutils.go @@ -20,6 +20,7 @@ import ( "strconv" "strings" + "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/onecloud/pkg/util/procutils" @@ -242,6 +243,10 @@ func LvResize(vg, lvPath string, size int64) error { // @param: lvPath string: should like /dev// func LvRemove(lvPath string) error { + if out, err := procutils.NewCommand("dd", "if=/dev/zero", fmt.Sprintf("of=%s", lvPath), "bs=10M", "count=16").Output(); err != nil { + log.Errorf("failed dd zero to lv %s: %s %s", lvPath, out, err) + } + out, err := procutils.NewRemoteCommandAsFarAsPossible("lvm", "lvremove", lvPath, "-y").Output() if err != nil { return errors.Wrapf(err, "LvRemove failed %s", out)