diff --git a/src/core/lvmdevice.cpp b/src/core/lvmdevice.cpp index 8b6c8e1..72eabde 100644 --- a/src/core/lvmdevice.cpp +++ b/src/core/lvmdevice.cpp @@ -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); diff --git a/src/core/lvmdevice.h b/src/core/lvmdevice.h index b69f52f..a59935d 100644 --- a/src/core/lvmdevice.h +++ b/src/core/lvmdevice.h @@ -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);