diff --git a/src/modules/partition/core/PartitionCoreModule.cpp b/src/modules/partition/core/PartitionCoreModule.cpp index cdb0a5b02..764c241ec 100644 --- a/src/modules/partition/core/PartitionCoreModule.cpp +++ b/src/modules/partition/core/PartitionCoreModule.cpp @@ -910,9 +910,23 @@ PartitionCoreModule::layoutApply( Device* dev, bool isEfi = PartUtils::isEfiSystem(); QList< Partition* > partList = m_partLayout->execute( dev, firstSector, lastSector, luksPassphrase, parent, role ); - foreach ( Partition* part, partList ) + // Partition::mountPoint() tells us where it is mounted **now**, while + // PartitionInfo::mountPoint() says where it will be mounted in the target system. + // .. the latter is more interesting. + // + // If we have a separate /boot, mark that one as bootable, otherwise mark + // the root / as bootable. + // + // TODO: perhaps the partition that holds the bootloader? + const QString boot = QStringLiteral( "/boot" ); + const QString root = QStringLiteral( "/" ); + const auto is_boot = [&](Partition*p) -> bool {return PartitionInfo::mountPoint(p) == boot || p->mountPoint() == boot;}; + const auto is_root = [&](Partition*p) -> bool {return PartitionInfo::mountPoint(p) == root || p->mountPoint() == root;}; + + const bool separate_boot_partition = std::find_if(partList.constBegin(), partList.constEnd(), is_boot) != partList.constEnd(); + for( Partition* part : partList ) { - if ( part->mountPoint() == "/" ) + if ( ( separate_boot_partition && is_boot(part)) || (!separate_boot_partition && is_root(part))) { createPartition( dev, part, part->activeFlags() | ( isEfi ? KPM_PARTITION_FLAG( None ) : KPM_PARTITION_FLAG( Boot ) ) );