Deactivate VG before removing it.

This commit is contained in:
Chantara Tith 2016-07-25 00:14:06 +07:00
parent cbcfcc770e
commit 90e5e9c83e
1 changed files with 8 additions and 1 deletions

View File

@ -395,8 +395,15 @@ 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;
ExternalCommand cmd(report, QStringLiteral("lvm"),
{ QStringLiteral("vgremove"),
dev.name() });
return (cmd.run(-1) && cmd.exitCode() == 0);
return (deactivated && cmd.run(-1) && cmd.exitCode() == 0);
}