Skip to content
Snippets Groups Projects
Select Git revision
  • f8cc0d73507c804b38afdf3325cc737d2e9f406f
  • master default protected
  • th/btop
  • th/ssh-config
  • th/rwth-afu
  • th/rhel
  • th/emacs-nox-gtk
7 results

ssh_config

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    PartitionActions.cpp 9.31 KiB
    /* === This file is part of Calamares - <https://github.com/calamares> ===
     *
     *   Copyright 2014-2017, Teo Mrnjavac <teo@kde.org>
     *   Copyright 2017-2018, Adriaan de Groot <groot@kde.org>
     *   Copyright 2019, Collabora Ltd <arnaud.ferraris@collabora.com>
     *
     *   Calamares is free software: you can redistribute it and/or modify
     *   it under the terms of the GNU General Public License as published by
     *   the Free Software Foundation, either version 3 of the License, or
     *   (at your option) any later version.
     *
     *   Calamares is distributed in the hope that it will be useful,
     *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
     *   GNU General Public License for more details.
     *
     *   You should have received a copy of the GNU General Public License
     *   along with Calamares. If not, see <http://www.gnu.org/licenses/>.
     */
    
    #include "PartitionActions.h"
    
    #include "core/KPMHelpers.h"
    #include "core/PartitionInfo.h"
    #include "core/PartitionCoreModule.h"
    #include "core/PartUtils.h"
    
    #include "utils/CalamaresUtilsSystem.h"
    #include "utils/Units.h"
    #include "utils/NamedEnum.h"
    
    #include "GlobalStorage.h"
    #include "JobQueue.h"
    #include "utils/Logger.h"
    
    #include <kpmcore/core/device.h>
    #include <kpmcore/core/partition.h>
    
    #include <QDir>
    
    namespace PartitionActions
    {
    using CalamaresUtils::operator""_GiB;
    using CalamaresUtils::operator""_MiB;
    
    qint64
    swapSuggestion( const qint64 availableSpaceB, Choices::SwapChoice swap )
    {
        if ( ( swap != Choices::SmallSwap ) && ( swap != Choices::FullSwap ) )
            return 0;
    
        // See partition.conf for explanation
        qint64 suggestedSwapSizeB = 0;
        auto memory = CalamaresUtils::System::instance()->getTotalMemoryB();
        qint64 availableRamB = memory.first;
        qreal overestimationFactor = memory.second;
    
        bool ensureSuspendToDisk = swap == Choices::FullSwap;
    
        // Ramp up quickly to 8GiB, then follow memory size
        if ( availableRamB <= 4_GiB )
            suggestedSwapSizeB = availableRamB * 2;
        else if ( availableRamB <= 8_GiB )
            suggestedSwapSizeB = 8_GiB;
        else
            suggestedSwapSizeB = availableRamB;
    
        // .. top out at 8GiB if we don't care about suspend
        if ( !ensureSuspendToDisk )
            suggestedSwapSizeB = qMin( 8_GiB, suggestedSwapSizeB );