--- calamares-1.0.1/src/modules/partition/gui/EraseDiskPage.cpp.orig 2015-05-21 12:53:55.003623191 +0200 +++ calamares-1.0.1/src/modules/partition/gui/EraseDiskPage.cpp 2015-05-21 15:26:40.937147517 +0200 @@ -36,6 +36,7 @@ #include #include #include +#include EraseDiskPage::EraseDiskPage( QWidget* parent ) : QWidget( parent ) @@ -170,18 +171,70 @@ m_core->createPartitionTable( dev, PartitionTable::msdos ); } +#define GiB * 1024ul * 1024ul * 1024ul + + qint64 total_size = (dev->totalSectors() - first_free_sector) * dev->logicalSectorSize(); + qint64 root_size = 30 GiB; + + QProcess p; + p.start( "awk", { "/MemTotal/ {print $2}", "/proc/meminfo" } ); + p.waitForFinished(); + QString memoryLine = p.readAllStandardOutput().simplified(); + // Set automatic swap size to RAM * 1.1 + qint64 swap_size = memoryLine.toLongLong() * 1152ul; + // No swap on small disks + if (total_size - swap_size < 30 GiB) swap_size = 0; + + // home partition if big enough disk + qint64 home_size = total_size - swap_size - 30 GiB; + if (home_size < 30 GiB) { + home_size = 0; + root_size = total_size - swap_size; + } + Partition* rootPartition = PMUtils::createNewPartition( dev->partitionTable(), *dev, PartitionRole( PartitionRole::Primary ), FileSystem::Ext4, first_free_sector, - dev->totalSectors() - 1 //last sector + first_free_sector + root_size / dev->logicalSectorSize() - 1 ); PartitionInfo::setMountPoint( rootPartition, "/" ); PartitionInfo::setFormat( rootPartition, true ); m_core->createPartition( dev, rootPartition ); + first_free_sector = first_free_sector + root_size / dev->logicalSectorSize(); + + if (swap_size > 0) { + Partition* swapPartition = PMUtils::createNewPartition( + dev->partitionTable(), + *dev, + PartitionRole( PartitionRole::Primary ), + FileSystem::LinuxSwap, + first_free_sector, + first_free_sector + swap_size / dev->logicalSectorSize() - 1 + ); + //PartitionInfo::setMountPoint( swapPartition, "" ); + PartitionInfo::setFormat( swapPartition, true ); + m_core->createPartition( dev, swapPartition ); + first_free_sector = first_free_sector + swap_size / dev->logicalSectorSize(); + } + + if (home_size > 0) { + Partition* homePartition = PMUtils::createNewPartition( + dev->partitionTable(), + *dev, + PartitionRole( PartitionRole::Primary ), + FileSystem::Ext4, + first_free_sector, + first_free_sector + home_size / dev->logicalSectorSize() - 1 + ); + PartitionInfo::setMountPoint( homePartition, "/home" ); + PartitionInfo::setFormat( homePartition, true ); + m_core->createPartition( dev, homePartition ); + } + m_core->setBootLoaderInstallPath( dev->deviceNode() ); { qDeleteAll( m_previewFrame->children() );