diff --git a/src/plugins/libparted/libpartedbackend.cpp b/src/plugins/libparted/libpartedbackend.cpp index 7c0e59a..db73577 100644 --- a/src/plugins/libparted/libpartedbackend.cpp +++ b/src/plugins/libparted/libpartedbackend.cpp @@ -384,12 +384,28 @@ void LibPartedBackend::scanDevicePartitions(Device& d, PedDisk* pedDisk) @param deviceNode the device node (e.g. "/dev/sda") @return the created Device object. callers need to free this. */ -DiskDevice* LibPartedBackend::scanDevice(const QString& deviceNode) +Device* LibPartedBackend::scanDevice(const QString& deviceNode) { PedDevice* pedDevice = ped_device_get(deviceNode.toLocal8Bit().constData()); if (pedDevice == nullptr) { Log(Log::warning) << xi18nc("@info:status", "Could not access device %1", deviceNode); + Log(Log::warning) << xi18nc("@info:status", "Checking if this device is LVM VG"); + + // Look if this device is a LVM VG + ExternalCommand checkVG(QStringLiteral("lvm"), { QStringLiteral("vgdisplay"), deviceNode }); + + if (checkVG.run(-1) && checkVG.exitCode() == 0) + { + QList availableDevices = scanDevices(); + + LvmDevice::scanSystemLVM(availableDevices); + + for (Device *device : qAsConst(availableDevices)) + if (device->deviceNode() == deviceNode) + return device; + } + return nullptr; } diff --git a/src/plugins/libparted/libpartedbackend.h b/src/plugins/libparted/libpartedbackend.h index 93ed320..238ec03 100644 --- a/src/plugins/libparted/libpartedbackend.h +++ b/src/plugins/libparted/libpartedbackend.h @@ -64,7 +64,7 @@ public: CoreBackendDevice* openDevice(const Device& d) override; CoreBackendDevice* openDeviceExclusive(const Device& d) override; bool closeDevice(CoreBackendDevice* core_device) override; - DiskDevice* scanDevice(const QString& deviceNode) override; + Device* scanDevice(const QString& deviceNode) override; QList scanDevices(bool excludeReadOnly = false) override; FileSystem::Type detectFileSystem(const QString& partitionPath) override; QString readLabel(const QString& deviceNode) const override; diff --git a/src/plugins/sfdisk/sfdiskbackend.cpp b/src/plugins/sfdisk/sfdiskbackend.cpp index 57a510d..bd641e6 100644 --- a/src/plugins/sfdisk/sfdiskbackend.cpp +++ b/src/plugins/sfdisk/sfdiskbackend.cpp @@ -182,6 +182,23 @@ Device* SfdiskBackend::scanDevice(const QString& deviceNode) scanDevicePartitions(*d, partitionTable[QLatin1String("partitions")].toArray()); return d; } + else + { + // Look if this device is a LVM VG + ExternalCommand checkVG(QStringLiteral("lvm"), { QStringLiteral("vgdisplay"), deviceNode }); + + if (checkVG.run(-1) && checkVG.exitCode() == 0) + { + qDebug() << "Trying to find LVM VG"; + QList availableDevices = scanDevices(); + + LvmDevice::scanSystemLVM(availableDevices); + + for (Device *device : qAsConst(availableDevices)) + if (device->deviceNode() == deviceNode) + return device; + } + } return nullptr; }