Skip to content
Snippets Groups Projects
Commit 27309619 authored by Teo Mrnjavac's avatar Teo Mrnjavac
Browse files

Optionally do not allow a swap partition smaller than physical RAM.

parent 35f4db93
Branches
Tags
No related merge requests found
......@@ -292,6 +292,23 @@ EraseDiskPage::swapSuggestion( const qint64 availableSpaceB ) const {
overestimationFactor = 1.10;
}
bool ensureSuspendToDisk =
Calamares::JobQueue::instance()->globalStorage()->
value( "ensureSuspendToDisk" ).toBool();
if ( ensureSuspendToDisk )
{
if ( availableRamB < 4 GiB )
suggestedSwapSizeB = qMax( 2 GiB, availableRamB * 2 );
else if ( availableRamB >= 4 GiB && availableRamB < 8 GiB )
suggestedSwapSizeB = 8 GiB;
else
suggestedSwapSizeB = availableRamB;
suggestedSwapSizeB *= overestimationFactor;
}
else //if we don't care about suspend to disk
{
if ( availableRamB < 2 GiB )
suggestedSwapSizeB = qMax( 2 GiB, availableRamB * 2 );
else if ( availableRamB >= 2 GiB && availableRamB < 8 GiB )
......@@ -303,11 +320,12 @@ EraseDiskPage::swapSuggestion( const qint64 availableSpaceB ) const {
suggestedSwapSizeB *= overestimationFactor;
// don't use more 10% of available space
// don't use more than 10% of available space
qreal maxSwapDiskRatio = 1.10;
qint64 maxSwapSizeB = availableSpaceB * maxSwapDiskRatio;
if ( suggestedSwapSizeB > maxSwapSizeB )
suggestedSwapSizeB = maxSwapSizeB;
}
cDebug() << "Suggested swap size:" << suggestedSwapSizeB / 1024. / 1024. /1024. << "GiB";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment