[partition] Add setting for defaultPartitionTableType

main
Gaël PORTAY 5 years ago
parent 9486ee6fbf
commit 70f8beb931

@ -118,6 +118,14 @@ doAutopartition( PartitionCoreModule* core, Device* dev, Choices::AutoPartitionO
// before that one, numbered 0..2047).
qint64 firstFreeSector = CalamaresUtils::bytesToSectors( empty_space_sizeB, dev->logicalSize() );
PartitionTable::TableType partType = PartitionTable::nameToTableType( o.defaultPartitionTableType );
if ( partType == PartitionTable::unknownTableType )
{
partType = isEfi ? PartitionTable::gpt : PartitionTable::msdos;
}
core->createPartitionTable( dev, partType );
if ( isEfi )
{
qint64 efiSectorCount = CalamaresUtils::bytesToSectors( uefisys_part_sizeB, dev->logicalSize() );
@ -127,7 +135,6 @@ doAutopartition( PartitionCoreModule* core, Device* dev, Choices::AutoPartitionO
// at firstFreeSector, we need efiSectorCount sectors, numbered
// firstFreeSector..firstFreeSector+efiSectorCount-1.
qint64 lastSector = firstFreeSector + efiSectorCount - 1;
core->createPartitionTable( dev, PartitionTable::gpt );
Partition* efiPartition = KPMHelpers::createNewPartition( dev->partitionTable(),
*dev,
PartitionRole( PartitionRole::Primary ),
@ -144,10 +151,6 @@ doAutopartition( PartitionCoreModule* core, Device* dev, Choices::AutoPartitionO
core->createPartition( dev, efiPartition, KPM_PARTITION_FLAG_ESP );
firstFreeSector = lastSector + 1;
}
else
{
core->createPartitionTable( dev, PartitionTable::msdos );
}
const bool mayCreateSwap
= ( o.swap == Config::SwapChoice::SmallSwap ) || ( o.swap == Config::SwapChoice::FullSwap );

@ -29,11 +29,13 @@ namespace Choices
{
struct ReplacePartitionOptions
{
QString defaultPartitionTableType; // e.g. "gpt" or "msdos"
QString defaultFsType; // e.g. "ext4" or "btrfs"
QString luksPassphrase; // optional
ReplacePartitionOptions( const QString& fs, const QString& luks )
: defaultFsType( fs )
ReplacePartitionOptions( const QString& pt, const QString& fs, const QString& luks )
: defaultPartitionTableType ( pt )
, defaultFsType( fs )
, luksPassphrase( luks )
{
}
@ -45,12 +47,13 @@ struct AutoPartitionOptions : ReplacePartitionOptions
quint64 requiredSpaceB; // estimated required space for root partition
Config::SwapChoice swap;
AutoPartitionOptions( const QString& fs,
AutoPartitionOptions( const QString& pt,
const QString& fs,
const QString& luks,
const QString& efi,
qint64 requiredBytes,
Config::SwapChoice s )
: ReplacePartitionOptions( fs, luks )
: ReplacePartitionOptions( pt, fs, luks )
, efiPartitionMountPoint( efi )
, requiredSpaceB( requiredBytes > 0 ? static_cast< quint64 >( requiredBytes ) : 0 )
, swap( s )

@ -448,7 +448,8 @@ ChoicePage::applyActionChoice( InstallChoice choice )
{
auto gs = Calamares::JobQueue::instance()->globalStorage();
PartitionActions::Choices::AutoPartitionOptions options { gs->value( "defaultFileSystemType" ).toString(),
PartitionActions::Choices::AutoPartitionOptions options { gs->value( "defaultPartitionTableType" ).toString(),
gs->value( "defaultFileSystemType" ).toString(),
m_encryptWidget->passphrase(),
gs->value( "efiSystemPartition" ).toString(),
CalamaresUtils::GiBtoBytes(
@ -805,7 +806,9 @@ ChoicePage::doReplaceSelectedPartition( const QModelIndex& current )
m_core,
selectedDevice(),
selectedPartition,
{ gs->value( "defaultFileSystemType" ).toString(), m_encryptWidget->passphrase() } );
{ gs->value( "defaultPartitionType" ).toString(),
gs->value( "defaultFileSystemType" ).toString(),
m_encryptWidget->passphrase() } );
Partition* homePartition = findPartitionByPath( { selectedDevice() }, *homePartitionPath );
if ( homePartition && doReuseHomePartition )

@ -574,6 +574,13 @@ PartitionViewStep::setConfigurationMap( const QVariantMap& configurationMap )
}
gs->insert( "defaultFileSystemType", fsRealName );
QString partitionTableName = CalamaresUtils::getString( configurationMap, "defaultPartitionTableType" );
if ( partitionTableName.isEmpty() )
{
cWarning() << "Partition-module setting *defaultPartitionTableType* is unset, "
"will use gpt for efi or msdos for bios";
}
gs->insert( "defaultPartitionTableType", partitionTableName );
// Now that we have the config, we load the PartitionCoreModule in the background
// because it could take a while. Then when it's done, we can set up the widgets

@ -85,7 +85,8 @@ ReplaceWidget::applyChanges()
Device* dev = model->device();
PartitionActions::doReplacePartition(
m_core, dev, partition, { gs->value( "defaultFileSystemType" ).toString(), QString() } );
m_core, dev, partition, { gs->value( "defaultPartitionTableType" ).toString(),
gs->value( "defaultFileSystemType" ).toString(), QString() } );
if ( m_isEfi )
{

@ -88,6 +88,20 @@ initialPartitioningChoice: none
# one of the items from the options.
initialSwapChoice: none
# Default partition table type, used when a "erase" disk is made.
#
# When erasing a disk, a new partition table is created on disk.
# In other cases, e.g. Replace and Alongside, as well as when using
# manual partitioning, this partition table exists already on disk
# and it is left unmodified.
#
# Suggested values: gpt, msdos
# If nothing is specified, Calamares defaults to "gpt" if system is
# efi or "msdos".
#
# Names are case-sensitive and defined by KPMCore.
# defaultPartitionTableType: msdos
# Default filesystem type, used when a "new" partition is made.
#
# When replacing a partition, the existing filesystem inside the

Loading…
Cancel
Save