From 252a88cb7fd60d2a526fc33f09608f644f9a3c28 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 25 May 2021 14:07:58 +0200 Subject: [PATCH] [partition] Check for suitable bios_grub partition. --- .../partition/gui/PartitionViewStep.cpp | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/modules/partition/gui/PartitionViewStep.cpp b/src/modules/partition/gui/PartitionViewStep.cpp index b1fa851ed..2e769576e 100644 --- a/src/modules/partition/gui/PartitionViewStep.cpp +++ b/src/modules/partition/gui/PartitionViewStep.cpp @@ -13,6 +13,7 @@ #include "gui/PartitionViewStep.h" +#include "core/BootLoaderModel.h" #include "core/Config.h" #include "core/DeviceModel.h" #include "core/KPMHelpers.h" @@ -36,6 +37,7 @@ #include "utils/NamedEnum.h" #include "utils/QtCompat.h" #include "utils/Retranslator.h" +#include "utils/Units.h" #include "utils/Variant.h" #include "widgets/WaitingWidget.h" @@ -403,8 +405,33 @@ shouldWarnForGPTOnBIOS( const PartitionCoreModule* core ) return false; } - cDebug() << core->bootLoaderInstallPath(); - + auto [ r, device ] = core->bootLoaderModel()->findBootLoader( core->bootLoaderInstallPath() ); + if ( device ) + { + auto* table = device->partitionTable(); + cDebug() << "Found device for bootloader" << device->deviceNode(); + if ( table && table->type() == PartitionTable::TableType::gpt ) + { + // So this is a BIOS system, and the bootloader will be installed on a GPT system + for ( const auto& partition : qAsConst( table->children() ) ) + { + using CalamaresUtils::Units::operator""_MiB; + if ( ( partition->activeFlags() & PartitionTable::Flag::BiosGrub ) + && ( partition->fileSystem().type() == FileSystem::Unformatted ) + && ( partition->capacity() >= 8_MiB ) ) + { + cDebug() << Logger::SubEntry << "Partition" << partition->partitionPath() + << "is a suitable bios_grub partition"; + return false; + } + } + } + cDebug() << Logger::SubEntry << "No suitable partition for bios_grub found"; + } + else + { + cDebug() << "Found no device for" << core->bootLoaderInstallPath(); + } return true; }