[partition] Check for LVs that will be formatted, don't close them
- when (manually) using an existing LV, it shouldn't be closed prior to formatting, since that kills the volume and then the path (/dev/myvg/mylv) no longer exists. Then creating the filesysytem on that device path fails.
This commit is contained in:
parent
7b45793b60
commit
b5dba9108c
@ -580,6 +580,42 @@ PartitionCoreModule::setPartitionFlags( Device* device, Partition* partition, Pa
|
|||||||
PartitionInfo::setFlags( partition, flags );
|
PartitionInfo::setFlags( partition, flags );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
STATICTEST QStringList
|
||||||
|
findEssentialLVs( const QList< PartitionCoreModule::DeviceInfo* >& infos )
|
||||||
|
{
|
||||||
|
QStringList doNotClose;
|
||||||
|
cDebug() << "Checking LVM use on" << infos.count() << "devices";
|
||||||
|
for ( const auto* info : infos )
|
||||||
|
{
|
||||||
|
if ( info->device->type() != Device::Type::LVM_Device )
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( const auto& j : qAsConst( info->jobs() ) )
|
||||||
|
{
|
||||||
|
FormatPartitionJob* format = dynamic_cast< FormatPartitionJob* >( j.data() );
|
||||||
|
if ( format )
|
||||||
|
{
|
||||||
|
// device->deviceNode() is /dev/<vg name>
|
||||||
|
// partition()->partitionPath() is /dev/<vg name>/<lv>
|
||||||
|
const auto* partition = format->partition();
|
||||||
|
const QString partPath = partition->partitionPath();
|
||||||
|
const QString devicePath = info->device->deviceNode() + '/';
|
||||||
|
const bool isLvm = partition->roles().has( PartitionRole::Lvm_Lv );
|
||||||
|
if ( isLvm && partPath.startsWith( devicePath ) )
|
||||||
|
{
|
||||||
|
cDebug() << Logger::SubEntry << partPath
|
||||||
|
<< "is an essential LV filesystem=" << partition->fileSystem().type();
|
||||||
|
QString lvName = partPath.right( partPath.length() - devicePath.length() );
|
||||||
|
doNotClose.append( info->device->name() + '-' + lvName );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return doNotClose;
|
||||||
|
}
|
||||||
|
|
||||||
Calamares::JobList
|
Calamares::JobList
|
||||||
PartitionCoreModule::jobs( const Config* config ) const
|
PartitionCoreModule::jobs( const Config* config ) const
|
||||||
{
|
{
|
||||||
@ -604,11 +640,15 @@ PartitionCoreModule::jobs( const Config* config ) const
|
|||||||
lst << automountControl;
|
lst << automountControl;
|
||||||
lst << Calamares::job_ptr( new ClearTempMountsJob() );
|
lst << Calamares::job_ptr( new ClearTempMountsJob() );
|
||||||
|
|
||||||
|
const QStringList doNotClose = findEssentialLVs( m_deviceInfos );
|
||||||
|
|
||||||
for ( const auto* info : m_deviceInfos )
|
for ( const auto* info : m_deviceInfos )
|
||||||
{
|
{
|
||||||
if ( info->isDirty() )
|
if ( info->isDirty() )
|
||||||
{
|
{
|
||||||
lst << Calamares::job_ptr( new ClearMountsJob( info->device.data() ) );
|
auto* job = new ClearMountsJob( info->device.data() );
|
||||||
|
job->setMapperExceptions( doNotClose );
|
||||||
|
lst << Calamares::job_ptr( job );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,6 +84,8 @@ public:
|
|||||||
PartitionModel* partitionModelAfter;
|
PartitionModel* partitionModelAfter;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct DeviceInfo;
|
||||||
|
|
||||||
PartitionCoreModule( QObject* parent = nullptr );
|
PartitionCoreModule( QObject* parent = nullptr );
|
||||||
~PartitionCoreModule() override;
|
~PartitionCoreModule() override;
|
||||||
|
|
||||||
@ -239,7 +241,6 @@ Q_SIGNALS:
|
|||||||
void deviceReverted( Device* device );
|
void deviceReverted( Device* device );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct DeviceInfo;
|
|
||||||
void refreshAfterModelChange();
|
void refreshAfterModelChange();
|
||||||
|
|
||||||
void doInit();
|
void doInit();
|
||||||
|
Loading…
Reference in New Issue
Block a user