diff --git a/src/core/lvmdevice.cpp b/src/core/lvmdevice.cpp index 37faa65..ad73c52 100644 --- a/src/core/lvmdevice.cpp +++ b/src/core/lvmdevice.cpp @@ -446,15 +446,28 @@ bool LvmDevice::createVG(Report& report, const QString vgname, const QStringList bool LvmDevice::removeVG(Report& report, LvmDevice& dev) { - bool deactivated = false; - ExternalCommand deactivate(report, QStringLiteral("lvm"), - { QStringLiteral("vgchange"), - QStringLiteral("--activate"), QStringLiteral("n"), - dev.name() }); - deactivated = deactivate.run(-1) && deactivate.exitCode() == 0; - + bool deactivated = deactivateVG(report, dev); ExternalCommand cmd(report, QStringLiteral("lvm"), { QStringLiteral("vgremove"), dev.name() }); return (deactivated && cmd.run(-1) && cmd.exitCode() == 0); } + +bool LvmDevice::deactivateVG(Report& report, const LvmDevice& dev) +{ + ExternalCommand deactivate(report, QStringLiteral("lvm"), + { QStringLiteral("vgchange"), + QStringLiteral("--activate"), QStringLiteral("n"), + dev.name() }); + return deactivate.run(-1) && deactivate.exitCode() == 0; +} + +bool LvmDevice::deactivateLV(Report& report, LvmDevice& dev, Partition& part) +{ + Q_UNUSED(dev); + ExternalCommand deactivate(report, QStringLiteral("lvm"), + { QStringLiteral("lvchange"), + QStringLiteral("--activate"), QStringLiteral("n"), + part.partitionPath() }); + return deactivate.run(-1) && deactivate.exitCode() == 0; +} diff --git a/src/core/lvmdevice.h b/src/core/lvmdevice.h index 6cb210b..f6732ff 100644 --- a/src/core/lvmdevice.h +++ b/src/core/lvmdevice.h @@ -74,6 +74,7 @@ public: static bool createLV(Report& report, LvmDevice& dev, Partition& part, const QString& lvname); static bool createLVSnapshot(Report& report, LvmDevice& dev, Partition& lvpart, const QString& name, const qint64 extents = 0); static bool resizeLV(Report& report, LvmDevice& dev, Partition& part); + static bool deactivateLV(Report& report, LvmDevice& dev, Partition& part); static bool removePV(Report& report, LvmDevice& dev, const QString& pvPath); static bool insertPV(Report& report, LvmDevice& dev, const QString& pvPath); @@ -81,6 +82,7 @@ public: static bool removeVG(Report& report, LvmDevice& dev); static bool createVG(Report& report, const QString vgname, const QStringList pvlist, const qint32 peSize = 4); // peSize in megabytes + static bool deactivateVG(Report& report, const LvmDevice& dev); protected: void initPartitions();