Add LVM snapshotting functionality.

This commit is contained in:
Chantara Tith 2016-08-01 19:20:20 +07:00 committed by Andrius Štikonas
parent 484c1765ed
commit c3c718615d
2 changed files with 18 additions and 0 deletions

View File

@ -339,6 +339,23 @@ bool LvmDevice::createLV(Report& report, LvmDevice& dev, Partition& part, const
return (cmd.run(-1) && cmd.exitCode() == 0);
}
bool LvmDevice::createLVSnapshot(Report& report, LvmDevice& dev, Partition& lvpart, const QString& name, const qint64 extents)
{
Q_UNUSED(dev);
QString numExtents = (extents > 0) ? QString::number(extents) :
QString::number(lvpart.length());
ExternalCommand cmd(report, QStringLiteral("lvm"),
{ QStringLiteral("lvcreate"),
QStringLiteral("--yes"),
QStringLiteral("--extents"),
numExtents,
QStringLiteral("--snapshot"),
QStringLiteral("--name"),
name,
lvpart.partitionPath() });
return (cmd.run(-1) && cmd.exitCode() == 0);
}
bool LvmDevice::resizeLV(Report& report, LvmDevice& dev, Partition& part)
{
Q_UNUSED(dev);

View File

@ -66,6 +66,7 @@ public:
static bool removeLV(Report& report, LvmDevice& dev, Partition& part);
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 removePV(Report& report, LvmDevice& dev, const QString& pvPath);