Tentative LUKS support for EraseAutopartition.

Partitioning only, install doesn't work yet.
main
Teo Mrnjavac 9 years ago
parent 0cc9560a99
commit 759ccae9f6

@ -98,7 +98,7 @@ swapSuggestion( const qint64 availableSpaceB )
void
doAutopartition( PartitionCoreModule* core, Device* dev )
doAutopartition( PartitionCoreModule* core, Device* dev, const QString& luksPassphrase )
{
bool isEfi = false;
if ( QDir( "/sys/firmware/efi/efivars" ).exists() )
@ -167,28 +167,60 @@ doAutopartition( PartitionCoreModule* core, Device* dev )
lastSectorForRoot -= suggestedSwapSizeB / dev->logicalSectorSize() + 1;
}
Partition* rootPartition = KPMHelpers::createNewPartition(
dev->partitionTable(),
*dev,
PartitionRole( PartitionRole::Primary ),
FileSystem::Ext4,
firstFreeSector,
lastSectorForRoot
);
Partition* rootPartition = nullptr;
if ( luksPassphrase.isEmpty() )
{
rootPartition = KPMHelpers::createNewPartition(
dev->partitionTable(),
*dev,
PartitionRole( PartitionRole::Primary ),
FileSystem::Ext4,
firstFreeSector,
lastSectorForRoot
);
}
else
{
rootPartition = KPMHelpers::createNewEncryptedPartition(
dev->partitionTable(),
*dev,
PartitionRole( PartitionRole::Primary ),
FileSystem::Ext4,
firstFreeSector,
lastSectorForRoot,
luksPassphrase
);
}
PartitionInfo::setFormat( rootPartition, true );
PartitionInfo::setMountPoint( rootPartition, "/" );
core->createPartition( dev, rootPartition );
if ( shouldCreateSwap )
{
Partition* swapPartition = KPMHelpers::createNewPartition(
dev->partitionTable(),
*dev,
PartitionRole( PartitionRole::Primary ),
FileSystem::LinuxSwap,
lastSectorForRoot + 1,
dev->totalSectors() - 1
);
Partition* swapPartition = nullptr;
if ( luksPassphrase.isEmpty() )
{
swapPartition = KPMHelpers::createNewPartition(
dev->partitionTable(),
*dev,
PartitionRole( PartitionRole::Primary ),
FileSystem::LinuxSwap,
lastSectorForRoot + 1,
dev->totalSectors() - 1
);
}
else
{
swapPartition = KPMHelpers::createNewEncryptedPartition(
dev->partitionTable(),
*dev,
PartitionRole( PartitionRole::Primary ),
FileSystem::LinuxSwap,
lastSectorForRoot + 1,
dev->totalSectors() - 1,
luksPassphrase
);
}
PartitionInfo::setFormat( swapPartition, true );
core->createPartition( dev, swapPartition );
}

@ -19,14 +19,21 @@
#ifndef PARTITIONACTIONS_H
#define PARTITIONACTIONS_H
#include <QString>
class PartitionCoreModule;
class Device;
class Partition;
namespace PartitionActions
{
void doAutopartition( PartitionCoreModule* core, Device* dev );
void doReplacePartition( PartitionCoreModule* core, Device* dev, Partition* partition );
void doAutopartition( PartitionCoreModule* core,
Device* dev,
const QString& luksPassphrase = QString() );
void doReplacePartition( PartitionCoreModule* core,
Device* dev,
Partition* partition );
}
#endif // PARTITIONACTIONS_H

Loading…
Cancel
Save