|
|
@ -2,6 +2,7 @@
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Copyright 2014-2017, Teo Mrnjavac <teo@kde.org>
|
|
|
|
* Copyright 2014-2017, Teo Mrnjavac <teo@kde.org>
|
|
|
|
* Copyright 2017-2018, Adriaan de Groot <groot@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
|
|
|
|
* 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
|
|
|
@ -28,6 +29,7 @@
|
|
|
|
#include "utils/Units.h"
|
|
|
|
#include "utils/Units.h"
|
|
|
|
#include "utils/NamedEnum.h"
|
|
|
|
#include "utils/NamedEnum.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "GlobalStorage.h"
|
|
|
|
#include "JobQueue.h"
|
|
|
|
#include "JobQueue.h"
|
|
|
|
#include "utils/Logger.h"
|
|
|
|
#include "utils/Logger.h"
|
|
|
|
|
|
|
|
|
|
|
@ -38,8 +40,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
namespace PartitionActions
|
|
|
|
namespace PartitionActions
|
|
|
|
{
|
|
|
|
{
|
|
|
|
using CalamaresUtils::GiBtoBytes;
|
|
|
|
|
|
|
|
using CalamaresUtils::MiBtoBytes;
|
|
|
|
|
|
|
|
using CalamaresUtils::operator""_GiB;
|
|
|
|
using CalamaresUtils::operator""_GiB;
|
|
|
|
using CalamaresUtils::operator""_MiB;
|
|
|
|
using CalamaresUtils::operator""_MiB;
|
|
|
|
|
|
|
|
|
|
|
@ -82,25 +82,10 @@ swapSuggestion( const qint64 availableSpaceB, Choices::SwapChoice swap )
|
|
|
|
return suggestedSwapSizeB;
|
|
|
|
return suggestedSwapSizeB;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
constexpr qint64
|
|
|
|
|
|
|
|
alignBytesToBlockSize( qint64 bytes, qint64 blocksize )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
qint64 blocks = bytes / blocksize;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( blocks * blocksize != bytes )
|
|
|
|
|
|
|
|
++blocks;
|
|
|
|
|
|
|
|
return blocks * blocksize;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
qint64
|
|
|
|
|
|
|
|
bytesToSectors( qint64 bytes, qint64 blocksize )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return alignBytesToBlockSize( alignBytesToBlockSize( bytes, blocksize), MiBtoBytes(1) ) / blocksize;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
doAutopartition( PartitionCoreModule* core, Device* dev, Choices::AutoPartitionOptions o )
|
|
|
|
doAutopartition( PartitionCoreModule* core, Device* dev, Choices::AutoPartitionOptions o )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
|
|
|
|
QString defaultFsType = o.defaultFsType;
|
|
|
|
QString defaultFsType = o.defaultFsType;
|
|
|
|
if ( FileSystem::typeForName( defaultFsType ) == FileSystem::Unknown )
|
|
|
|
if ( FileSystem::typeForName( defaultFsType ) == FileSystem::Unknown )
|
|
|
|
defaultFsType = "ext4";
|
|
|
|
defaultFsType = "ext4";
|
|
|
@ -109,19 +94,27 @@ doAutopartition( PartitionCoreModule* core, Device* dev, Choices::AutoPartitionO
|
|
|
|
|
|
|
|
|
|
|
|
// Partition sizes are expressed in MiB, should be multiples of
|
|
|
|
// Partition sizes are expressed in MiB, should be multiples of
|
|
|
|
// the logical sector size (usually 512B). EFI starts with 2MiB
|
|
|
|
// 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).
|
|
|
|
// 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 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,
|
|
|
|
// 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
|
|
|
|
// the first free sector has number 2048 (and there are 2048 sectors
|
|
|
|
// before that one, numbered 0..2047).
|
|
|
|
// before that one, numbered 0..2047).
|
|
|
|
qint64 firstFreeSector = bytesToSectors( empty_space_sizeB, dev->logicalSize() );
|
|
|
|
qint64 firstFreeSector = PartUtils::bytesToSectors( empty_space_sizeB, dev->logicalSize() );
|
|
|
|
|
|
|
|
|
|
|
|
if ( isEfi )
|
|
|
|
if ( isEfi )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
qint64 efiSectorCount = bytesToSectors( uefisys_part_sizeB, dev->logicalSize() );
|
|
|
|
qint64 efiSectorCount = PartUtils::bytesToSectors( uefisys_part_sizeB, dev->logicalSize() );
|
|
|
|
Q_ASSERT( efiSectorCount > 0 );
|
|
|
|
Q_ASSERT( efiSectorCount > 0 );
|
|
|
|
|
|
|
|
|
|
|
|
// Since sectors count from 0, and this partition is created starting
|
|
|
|
// Since sectors count from 0, and this partition is created starting
|
|
|
|