diff --git a/src/modules/partition/core/PartUtils.cpp b/src/modules/partition/core/PartUtils.cpp index 75a33bf94..4e8b7e8ba 100644 --- a/src/modules/partition/core/PartUtils.cpp +++ b/src/modules/partition/core/PartUtils.cpp @@ -536,6 +536,15 @@ parseSizeString( const QString& sizeString, SizeUnit* unit ) return value; } +qint64 +parseSizeString( const QString& sizeString, qint64 totalSize ) +{ + SizeUnit unit; + double value = parseSizeString( sizeString, &unit ); + + return sizeToBytes( value, unit, totalSize ); +} + qint64 sizeToSectors( double size, SizeUnit unit, qint64 totalSectors, qint64 logicalSize ) { diff --git a/src/modules/partition/core/PartUtils.h b/src/modules/partition/core/PartUtils.h index 8b811fd6d..0ad559a60 100644 --- a/src/modules/partition/core/PartUtils.h +++ b/src/modules/partition/core/PartUtils.h @@ -107,6 +107,14 @@ QString findFS( QString fsName, FileSystem::Type* fsType ); */ double parseSizeString( const QString& sizeString, SizeUnit* unit ); +/** + * @brief Parse a partition size string and return its value in bytes. + * @param sizeString the string to parse. + * @param totalSize the size of the selected drive (used when the size is expressed in %) + * @return the size value in bytes. + */ +qint64 parseSizeString( const QString& sizeString, qint64 totalSize ); + /** * @brief Convert a partition size to a sectors count. * @param size the partition size. diff --git a/src/modules/partition/core/PartitionActions.cpp b/src/modules/partition/core/PartitionActions.cpp index 01e794ff6..4172002fa 100644 --- a/src/modules/partition/core/PartitionActions.cpp +++ b/src/modules/partition/core/PartitionActions.cpp @@ -29,6 +29,7 @@ #include "utils/Units.h" #include "utils/NamedEnum.h" +#include "GlobalStorage.h" #include "JobQueue.h" #include "utils/Logger.h" @@ -84,6 +85,7 @@ swapSuggestion( const qint64 availableSpaceB, Choices::SwapChoice swap ) void doAutopartition( PartitionCoreModule* core, Device* dev, Choices::AutoPartitionOptions o ) { + Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage(); QString defaultFsType = o.defaultFsType; if ( FileSystem::typeForName( defaultFsType ) == FileSystem::Unknown ) defaultFsType = "ext4"; @@ -92,10 +94,18 @@ doAutopartition( PartitionCoreModule* core, Device* dev, Choices::AutoPartitionO // Partition sizes are expressed in MiB, should be multiples of // the logical sector size (usually 512B). EFI starts with 2MiB - // empty and a 300MiB EFI boot partition, while BIOS starts at + // empty and a EFI boot partition, while BIOS starts at // the 1MiB boundary (usually sector 2048). - int uefisys_part_sizeB = isEfi ? 300_MiB : 0_MiB; int empty_space_sizeB = isEfi ? 2_MiB : 1_MiB; + int uefisys_part_sizeB = 0_MiB; + + if ( isEfi ) + { + if ( gs->contains( "efiSystemPartitionSize" ) ) + uefisys_part_sizeB = PartUtils::parseSizeString( gs->value( "efiSystemPartitionSize" ).toString(), dev->capacity() ); + else + uefisys_part_sizeB = 300_MiB; + } // Since sectors count from 0, if the space is 2048 sectors in size, // the first free sector has number 2048 (and there are 2048 sectors diff --git a/src/modules/partition/gui/PartitionViewStep.cpp b/src/modules/partition/gui/PartitionViewStep.cpp index 6fc8b0129..ffeb8c055 100644 --- a/src/modules/partition/gui/PartitionViewStep.cpp +++ b/src/modules/partition/gui/PartitionViewStep.cpp @@ -3,7 +3,7 @@ * Copyright 2014, Aurélien Gâteau * Copyright 2014-2017, Teo Mrnjavac * Copyright 2018, Adriaan de Groot - * Copyright 2019, Collabora Ltd + * Copyright 2019, Collabora Ltd * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -489,6 +489,12 @@ PartitionViewStep::setConfigurationMap( const QVariantMap& configurationMap ) efiSP = QStringLiteral( "/boot/efi" ); gs->insert( "efiSystemPartition", efiSP ); + // Read and parse key efiSystemPartitionSize + if ( configurationMap.contains( "efiSystemPartitionSize" ) ) + { + gs->insert( "efiSystemPartitionSize", CalamaresUtils::getString( configurationMap, "efiSystemPartitionSize" ) ); + } + // SWAP SETTINGS // // This is a bit convoluted because there's legacy settings to handle as well diff --git a/src/modules/partition/partition.conf b/src/modules/partition/partition.conf index f812b67aa..66f40020c 100644 --- a/src/modules/partition/partition.conf +++ b/src/modules/partition/partition.conf @@ -3,6 +3,10 @@ # etc.) use just /boot. efiSystemPartition: "/boot/efi" +# This optional setting specifies the size of the EFI system partition. +# If nothing is specified, the default size of 300MiB will be used. +# efiSystemPartitionSize: 300M + # In autogenerated partitioning, allow the user to select a swap size? # If there is exactly one choice, no UI is presented, and the user # cannot make a choice -- this setting is used. If there is more than