diff --git a/src/modules/partition/PartitionViewStep.cpp b/src/modules/partition/PartitionViewStep.cpp index 01dd7098b..a012938bf 100644 --- a/src/modules/partition/PartitionViewStep.cpp +++ b/src/modules/partition/PartitionViewStep.cpp @@ -527,60 +527,91 @@ PartitionViewStep::onLeave() Logger::Once o; const bool okType = esp && PartUtils::isEfiFilesystemSuitableType( esp ); - const bool okSize = esp && PartUtils::isEfiFilesystemSuitableSize( esp ); + const bool okRecommendedSize = esp && PartUtils::isEfiFilesystemSuitableSize( esp ); + const bool okMinimumSize = esp && PartUtils::isEfiFilesystemSuitableMinimumSize( esp ); const bool okFlag = esp && PartUtils::isEfiBootable( esp ); - if ( !esp ) - { - message = tr( "No EFI system partition configured" ); - } - else if ( !( okType && okSize && okFlag ) ) - { - message = tr( "EFI system partition configured incorrectly" ); - } + const bool espExistsButIsWrong = esp && !( okType && okMinimumSize && okFlag ); + + const QString genericWrongnessMessage = tr( "An EFI system partition is necessary to start %1." + "

" + "To configure an EFI system partition, go back and " + "select or create a suitable filesystem." ) + .arg( branding->shortProductName() ); + const QString genericRecommendationMessage + = tr( "An EFI system partition is necessary to start %1." + "

" + "The EFI system partition does not meet recommendations. It is " + "recommended to go back and " + "select or create a suitable filesystem." ) + .arg( branding->shortProductName() ); + + const QString wrongMountPointMessage + = tr( "The filesystem must be mounted on %1." ).arg( espMountPoint ); + const QString wrongTypeMessage = tr( "The filesystem must have type FAT32." ); + const QString wrongFlagMessage = tr( "The filesystem must have flag %1 set." ) + .arg( PartitionTable::flagName( PartitionTable::Flag::Boot ) ); + + // Three flavors of size-is-wrong + using Calamares::Units::operator""_MiB; + + const qint64 atLeastBytes = static_cast< qint64 >( PartUtils::efiFilesystemMinimumSize() ); + const auto atLeastMiB = Calamares::BytesToMiB( atLeastBytes ); + + const QString requireConfiguredSize + = tr( "The filesystem must be at least %1 MiB in size." ).arg( atLeastMiB ); + const QString requiredMinimumSize + = tr( "The filesystem must be at least %1 MiB in size." ).arg( Calamares::BytesToMiB( 32_MiB ) ); + const QString suggestConfiguredSize + = tr( "The minimum recommended size for the filesystem is %1 MiB." ).arg( atLeastMiB ); + + + const QString mayFail = tr( "You can continue without setting up an EFI system " + "partition but your system may fail to start." ); + const QString possibleFail = tr( "You can continue with this EFI system " + "partition configuration but your system may fail to start." ); + + const QString startList = QStringLiteral( "



" ); + + auto listItem = []( QString s ) -> QString + { return s.prepend( QStringLiteral( "
  • " ) ).append( QStringLiteral( "
  • " ) ); }; - if ( !esp || !( okType && okSize && okFlag ) ) - { - description = tr( "An EFI system partition is necessary to start %1." - "

    " - "To configure an EFI system partition, go back and " - "select or create a suitable filesystem." ) - .arg( branding->shortProductName() ); - } if ( !esp ) { cDebug() << o << "No ESP mounted"; - description.append( ' ' ); - description.append( - tr( "The filesystem must be mounted on %1." ).arg( espMountPoint ) ); + message = tr( "No EFI system partition configured" ); + + description = genericWrongnessMessage + startList + listItem( wrongMountPointMessage ) + + listItem( requireConfiguredSize ) + listItem( wrongTypeMessage ) + listItem( wrongFlagMessage ) + + endList + mayFail; } - if ( !okType ) + else if ( espExistsButIsWrong ) { - cDebug() << o << "ESP wrong type"; - description.append( ' ' ); - description.append( tr( "The filesystem must have type FAT32." ) ); + message = tr( "EFI system partition configured incorrectly" ); + + description = genericWrongnessMessage + startList; + if ( !okMinimumSize ) + { + description.append( listItem( requiredMinimumSize ) ); + } + if ( !okType ) + { + description.append( listItem( wrongTypeMessage ) ); + } + if ( !okFlag ) + { + description.append( listItem( wrongFlagMessage ) ); + } + description.append( endList ); + description.append( mayFail ); } - if ( !okSize ) + else if ( !okRecommendedSize ) { - cDebug() << o << "ESP too small"; - const qint64 atLeastBytes = static_cast< qint64 >( PartUtils::efiFilesystemMinimumSize() ); - const auto atLeastMiB = Calamares::BytesToMiB( atLeastBytes ); - description.append( ' ' ); - description.append( tr( "The filesystem must be at least %1 MiB in size." ).arg( atLeastMiB ) ); - } - if ( !okFlag ) - { - cDebug() << o << "ESP missing flag"; - description.append( ' ' ); - description.append( tr( "The filesystem must have flag %1 set." ) - .arg( PartitionTable::flagName( PartitionTable::Flag::Boot ) ) ); - } - if ( !description.isEmpty() ) - { - description.append( "

    " ); - description.append( tr( "You can continue without setting up an EFI system " - "partition but your system may fail to start." ) ); + message = tr( "EFI system partition recommendation" ); + description = genericRecommendationMessage + suggestConfiguredSize + possibleFail; } + if ( !message.isEmpty() ) { QMessageBox mb( QMessageBox::Warning, message, description, QMessageBox::Ok, m_manualPartitionPage ); diff --git a/src/modules/partition/core/PartUtils.cpp b/src/modules/partition/core/PartUtils.cpp index 8c646e312..ad39bba37 100644 --- a/src/modules/partition/core/PartUtils.cpp +++ b/src/modules/partition/core/PartUtils.cpp @@ -485,7 +485,29 @@ isEfiFilesystemSuitableSize( const Partition* candidate ) } else { - cWarning() << "Filesystem for EFI is too small (" << size << "bytes)"; + cWarning() << "Filesystem for EFI is smaller than recommended (" << size << "bytes)"; + return false; + } +} + +bool +isEfiFilesystemSuitableMinimumSize( const Partition* candidate ) +{ + using Calamares::Units::operator""_MiB; + + auto size = candidate->capacity(); // bytes + if ( size <= 0 ) + { + return false; + } + + if ( size >= 32_MiB ) + { + return true; + } + else + { + cWarning() << "Filesystem for EFI is below minimum (" << size << "bytes)"; return false; } } diff --git a/src/modules/partition/core/PartUtils.h b/src/modules/partition/core/PartUtils.h index a6f036710..98a1c1ab3 100644 --- a/src/modules/partition/core/PartUtils.h +++ b/src/modules/partition/core/PartUtils.h @@ -99,6 +99,12 @@ bool isEfiFilesystemSuitableType( const Partition* candidate ); */ bool isEfiFilesystemSuitableSize( const Partition* candidate ); +/** + * @brief Is the @p candidate suitable as an EFI boot partition? + * This checks the bonkers-small minimum of 32MiB. + */ +bool isEfiFilesystemSuitableMinimumSize( const Partition* candidate ); + /** @brief Returns the minimum size of an EFI boot partition in bytes. * * This is determined as 300MiB, based on the FAT32 standard