fix(host): dd zero to lv wife partitions on lvremove (#24527)

This commit is contained in:
wanyaoqi
2026-03-23 19:01:21 +08:00
committed by GitHub
parent 010ca7d2e2
commit c21af671d6

View File

@@ -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/<vg>/<lv>
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)