mirror of
https://hubproxy.babadafafafafa.cn/https://github.com/yunionio/cloudpods.git
synced 2026-09-20 08:03:53 +08:00
fix(host): dd zero to lv wife partitions on lvremove (#24527)
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user