Add optional config value neverCreateSwap in partition module.
CAL-458 #close The feature has landed in master, please test.
This commit is contained in:
parent
20ce3e4c47
commit
c1747c81b4
@ -100,13 +100,13 @@ swapSuggestion( const qint64 availableSpaceB )
|
|||||||
void
|
void
|
||||||
doAutopartition( PartitionCoreModule* core, Device* dev, const QString& luksPassphrase )
|
doAutopartition( PartitionCoreModule* core, Device* dev, const QString& luksPassphrase )
|
||||||
{
|
{
|
||||||
|
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
|
||||||
|
|
||||||
bool isEfi = false;
|
bool isEfi = false;
|
||||||
if ( QDir( "/sys/firmware/efi/efivars" ).exists() )
|
if ( QDir( "/sys/firmware/efi/efivars" ).exists() )
|
||||||
isEfi = true;
|
isEfi = true;
|
||||||
|
|
||||||
QString defaultFsType = Calamares::JobQueue::instance()->
|
QString defaultFsType = gs->value( "defaultFileSystemType" ).toString();
|
||||||
globalStorage()->
|
|
||||||
value( "defaultFileSystemType" ).toString();
|
|
||||||
if ( FileSystem::typeForName( defaultFsType ) == FileSystem::Unknown )
|
if ( FileSystem::typeForName( defaultFsType ) == FileSystem::Unknown )
|
||||||
defaultFsType = "ext4";
|
defaultFsType = "ext4";
|
||||||
|
|
||||||
@ -144,9 +144,7 @@ doAutopartition( PartitionCoreModule* core, Device* dev, const QString& luksPass
|
|||||||
PartitionTable::FlagEsp
|
PartitionTable::FlagEsp
|
||||||
);
|
);
|
||||||
PartitionInfo::setFormat( efiPartition, true );
|
PartitionInfo::setFormat( efiPartition, true );
|
||||||
PartitionInfo::setMountPoint( efiPartition, Calamares::JobQueue::instance()
|
PartitionInfo::setMountPoint( efiPartition, gs->value( "efiSystemPartition" )
|
||||||
->globalStorage()
|
|
||||||
->value( "efiSystemPartition" )
|
|
||||||
.toString() );
|
.toString() );
|
||||||
core->createPartition( dev, efiPartition, PartitionTable::FlagEsp | PartitionTable::FlagBoot );
|
core->createPartition( dev, efiPartition, PartitionTable::FlagEsp | PartitionTable::FlagBoot );
|
||||||
firstFreeSector = lastSector + 1;
|
firstFreeSector = lastSector + 1;
|
||||||
@ -156,17 +154,21 @@ doAutopartition( PartitionCoreModule* core, Device* dev, const QString& luksPass
|
|||||||
core->createPartitionTable( dev, PartitionTable::msdos );
|
core->createPartitionTable( dev, PartitionTable::msdos );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const bool mayCreateSwap = !gs->value( "neverCreateSwap" ).toBool();
|
||||||
bool shouldCreateSwap = false;
|
bool shouldCreateSwap = false;
|
||||||
|
qint64 suggestedSwapSizeB = 0;
|
||||||
|
|
||||||
|
if ( mayCreateSwap )
|
||||||
|
{
|
||||||
qint64 availableSpaceB = ( dev->totalLogical() - firstFreeSector ) * dev->logicalSize();
|
qint64 availableSpaceB = ( dev->totalLogical() - firstFreeSector ) * dev->logicalSize();
|
||||||
qint64 suggestedSwapSizeB = swapSuggestion( availableSpaceB );
|
suggestedSwapSizeB = swapSuggestion( availableSpaceB );
|
||||||
qint64 requiredSpaceB =
|
qint64 requiredSpaceB =
|
||||||
( Calamares::JobQueue::instance()->
|
( gs->value( "requiredStorageGB" ).toDouble() + 0.1 + 2.0 ) GiB +
|
||||||
globalStorage()->
|
|
||||||
value( "requiredStorageGB" ).toDouble() + 0.1 + 2.0 ) GiB +
|
|
||||||
suggestedSwapSizeB;
|
suggestedSwapSizeB;
|
||||||
|
|
||||||
// If there is enough room for ESP + root + swap, create swap, otherwise don't.
|
// If there is enough room for ESP + root + swap, create swap, otherwise don't.
|
||||||
shouldCreateSwap = availableSpaceB > requiredSpaceB;
|
shouldCreateSwap = availableSpaceB > requiredSpaceB;
|
||||||
|
}
|
||||||
|
|
||||||
qint64 lastSectorForRoot = dev->totalLogical() - 1; //last sector of the device
|
qint64 lastSectorForRoot = dev->totalLogical() - 1; //last sector of the device
|
||||||
if ( shouldCreateSwap )
|
if ( shouldCreateSwap )
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||||
*
|
*
|
||||||
* Copyright 2014, Aurélien Gâteau <agateau@kde.org>
|
* Copyright 2014, Aurélien Gâteau <agateau@kde.org>
|
||||||
* Copyright 2014-2016, Teo Mrnjavac <teo@kde.org>
|
* Copyright 2014-2017, Teo Mrnjavac <teo@kde.org>
|
||||||
*
|
*
|
||||||
* Calamares is free software: you can redistribute it and/or modify
|
* Calamares is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -503,6 +503,16 @@ PartitionViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
|||||||
gs->insert( "ensureSuspendToDisk", true );
|
gs->insert( "ensureSuspendToDisk", true );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( configurationMap.contains( "neverCreateSwap" ) &&
|
||||||
|
configurationMap.value( "neverCreateSwap" ).type() == QVariant::Bool )
|
||||||
|
{
|
||||||
|
gs->insert( "neverCreateSwap", configurationMap.value( "neverCreateSwap" ).toBool() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gs->insert( "neverCreateSwap", false );
|
||||||
|
}
|
||||||
|
|
||||||
if ( configurationMap.contains( "drawNestedPartitions" ) &&
|
if ( configurationMap.contains( "drawNestedPartitions" ) &&
|
||||||
configurationMap.value( "drawNestedPartitions" ).type() == QVariant::Bool )
|
configurationMap.value( "drawNestedPartitions" ).type() == QVariant::Bool )
|
||||||
{
|
{
|
||||||
|
@ -3,9 +3,16 @@
|
|||||||
# etc.) use just /boot.
|
# etc.) use just /boot.
|
||||||
efiSystemPartition: "/boot/efi"
|
efiSystemPartition: "/boot/efi"
|
||||||
|
|
||||||
# Make sure an autogenerated swap partition is big enough for hibernation
|
# Make sure an autogenerated swap partition is big enough for hibernation in
|
||||||
|
# automated partitioning modes.
|
||||||
|
# Default is true.
|
||||||
ensureSuspendToDisk: true
|
ensureSuspendToDisk: true
|
||||||
|
|
||||||
|
# Never create swap partitions in automated partitioning modes.
|
||||||
|
# If this is true, ensureSuspendToDisk is ignored.
|
||||||
|
# Default is false.
|
||||||
|
neverCreateSwap: false
|
||||||
|
|
||||||
# Correctly draw nested (e.g. logical) partitions as such.
|
# Correctly draw nested (e.g. logical) partitions as such.
|
||||||
drawNestedPartitions: false
|
drawNestedPartitions: false
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user