From 6ae7a6b470a6a26ca3bc6febad7eeaf873e4a87d Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 9 Nov 2018 16:57:20 +0100 Subject: [PATCH 1/7] Changes: add aliveafter1000 to contributors for 3.2.3 Several PRs from aliveafter1000 (no real name known) were discussed and this branch contains re-formatted and slimmed- down changes that implement those PRs. --- CHANGES | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES b/CHANGES index 7094f5866..f8b62be07 100644 --- a/CHANGES +++ b/CHANGES @@ -7,6 +7,7 @@ website will have to do for older versions. This release contains contributions from (alphabetically by first name): - Alf Gaida + - aliveafter1000 - Caio Carvalho - Kevin Kofler - Philip Mueller From 8144295e989c17668502400dbb20a90aa25dc6a8 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sun, 11 Nov 2018 13:55:46 +0100 Subject: [PATCH 2/7] [partition] Make new partition flags explicit Suggested by aliveafter1000: having a default value, and then filling in the default in one place it is used and not others, is weird. Instead of dropping the one use, remove the default value: partition flags are important enough to be explicit. --- src/modules/partition/core/KPMHelpers.h | 4 ++-- .../partition/core/PartitionActions.cpp | 18 ++++++++++++------ src/modules/partition/gui/ChoicePage.cpp | 14 ++++++++++---- .../partition/tests/PartitionJobTests.cpp | 10 +++++++++- 4 files changed, 33 insertions(+), 13 deletions(-) diff --git a/src/modules/partition/core/KPMHelpers.h b/src/modules/partition/core/KPMHelpers.h index c9d9a30f9..0bcc533fb 100644 --- a/src/modules/partition/core/KPMHelpers.h +++ b/src/modules/partition/core/KPMHelpers.h @@ -89,7 +89,7 @@ Partition* createNewPartition( PartitionNode* parent, FileSystem::Type fsType, qint64 firstSector, qint64 lastSector, - PartitionTable::Flags flags = PartitionTable::FlagNone ); + PartitionTable::Flags flags ); Partition* createNewEncryptedPartition( PartitionNode* parent, const Device& device, @@ -98,7 +98,7 @@ Partition* createNewEncryptedPartition( PartitionNode* parent, qint64 firstSector, qint64 lastSector, const QString& passphrase, - PartitionTable::Flags flags = PartitionTable::FlagNone ); + PartitionTable::Flags flags ); Partition* clonePartition( Device* device, Partition* partition ); diff --git a/src/modules/partition/core/PartitionActions.cpp b/src/modules/partition/core/PartitionActions.cpp index 677c3778d..458961d2f 100644 --- a/src/modules/partition/core/PartitionActions.cpp +++ b/src/modules/partition/core/PartitionActions.cpp @@ -204,7 +204,8 @@ doAutopartition( PartitionCoreModule* core, Device* dev, const QString& luksPass PartitionRole( PartitionRole::Primary ), FileSystem::typeForName( defaultFsType ), firstFreeSector, - lastSectorForRoot + lastSectorForRoot, + PartitionTable::FlagNone ); } else @@ -216,7 +217,8 @@ doAutopartition( PartitionCoreModule* core, Device* dev, const QString& luksPass FileSystem::typeForName( defaultFsType ), firstFreeSector, lastSectorForRoot, - luksPassphrase + luksPassphrase, + PartitionTable::FlagNone ); } PartitionInfo::setFormat( rootPartition, true ); @@ -234,7 +236,8 @@ doAutopartition( PartitionCoreModule* core, Device* dev, const QString& luksPass PartitionRole( PartitionRole::Primary ), FileSystem::LinuxSwap, lastSectorForRoot + 1, - dev->totalLogical() - 1 + dev->totalLogical() - 1, + PartitionTable::FlagNone ); } else @@ -246,7 +249,8 @@ doAutopartition( PartitionCoreModule* core, Device* dev, const QString& luksPass FileSystem::LinuxSwap, lastSectorForRoot + 1, dev->totalLogical() - 1, - luksPassphrase + luksPassphrase, + PartitionTable::FlagNone ); } PartitionInfo::setFormat( swapPartition, true ); @@ -296,7 +300,8 @@ doReplacePartition( PartitionCoreModule* core, newRoles, FileSystem::typeForName( defaultFsType ), partition->firstSector(), - partition->lastSector() + partition->lastSector(), + PartitionTable::FlagNone ); } else @@ -308,7 +313,8 @@ doReplacePartition( PartitionCoreModule* core, FileSystem::typeForName( defaultFsType ), partition->firstSector(), partition->lastSector(), - luksPassphrase + luksPassphrase, + PartitionTable::FlagNone ); } PartitionInfo::setMountPoint( newPartition, "/" ); diff --git a/src/modules/partition/gui/ChoicePage.cpp b/src/modules/partition/gui/ChoicePage.cpp index 9bc571459..74410ee80 100644 --- a/src/modules/partition/gui/ChoicePage.cpp +++ b/src/modules/partition/gui/ChoicePage.cpp @@ -635,7 +635,8 @@ ChoicePage::doAlongsideApply() candidate->roles(), FileSystem::typeForName( m_defaultFsType ), newLastSector + 2, // * - oldLastSector + oldLastSector, + PartitionTable::FlagNone ); } else @@ -647,7 +648,8 @@ ChoicePage::doAlongsideApply() FileSystem::typeForName( m_defaultFsType ), newLastSector + 2, // * oldLastSector, - luksPassphrase + luksPassphrase, + PartitionTable::FlagNone ); } PartitionInfo::setMountPoint( newPartition, "/" ); @@ -735,7 +737,9 @@ ChoicePage::doReplaceSelectedPartition( const QModelIndex& current ) FileSystem::typeForName( m_defaultFsType ), selectedPartition->firstSector(), selectedPartition->lastSector(), - m_encryptWidget->passphrase() ); + m_encryptWidget->passphrase(), + PartitionTable::FlagNone + ); } else { @@ -745,7 +749,9 @@ ChoicePage::doReplaceSelectedPartition( const QModelIndex& current ) newRoles, FileSystem::typeForName( m_defaultFsType ), selectedPartition->firstSector(), - selectedPartition->lastSector() ); + selectedPartition->lastSector(), + PartitionTable::FlagNone + ); } PartitionInfo::setMountPoint( newPartition, "/" ); diff --git a/src/modules/partition/tests/PartitionJobTests.cpp b/src/modules/partition/tests/PartitionJobTests.cpp index de10631a0..d3fd67c12 100644 --- a/src/modules/partition/tests/PartitionJobTests.cpp +++ b/src/modules/partition/tests/PartitionJobTests.cpp @@ -358,7 +358,15 @@ PartitionJobTests::testResizePartition() Partition* freePartition = firstFreePartition( m_device->partitionTable() ); QVERIFY( freePartition ); - Partition* partition = KPMHelpers::createNewPartition( freePartition->parent(), *m_device, PartitionRole( PartitionRole::Primary ), FileSystem::Ext4, oldFirst, oldLast ); + Partition* partition = KPMHelpers::createNewPartition( + freePartition->parent(), + *m_device, + PartitionRole( PartitionRole::Primary ), + FileSystem::Ext4, + oldFirst, + oldLast, + PartitionTable::FlagNone + ); CreatePartitionJob* job = new CreatePartitionJob( m_device.data(), partition ); job->updatePreview(); m_queue.enqueue( job_ptr( job ) ); From a1143e8fef7b558836c941df6bb75576e4231cc1 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 12 Nov 2018 14:16:33 +0100 Subject: [PATCH 3/7] [partition] Document flags parameter to createPartition() --- src/modules/partition/core/PartitionCoreModule.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/modules/partition/core/PartitionCoreModule.h b/src/modules/partition/core/PartitionCoreModule.h index 704fff322..15dadc7f5 100644 --- a/src/modules/partition/core/PartitionCoreModule.h +++ b/src/modules/partition/core/PartitionCoreModule.h @@ -128,6 +128,12 @@ public: void createPartitionTable( Device* device, PartitionTable::TableType type ); + /** + * @brief Add a job to do the actual partition-creation. + * + * If @p flags is not FlagNone, then the given flags are + * applied to the newly-created partition. + */ void createPartition( Device* device, Partition* partition, PartitionTable::Flags flags = PartitionTable::FlagNone ); From 9459ef7d93885ac96763e6514e08f9967d377549 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 12 Nov 2018 15:15:22 +0100 Subject: [PATCH 4/7] [partition] Set FlagBoot for the root partition - This only applies to legacy (non-EFI) BIOS systems, and adds the FlagBoot to whatever is already set for the root filesystem, and only when autopartitioning the device. Submitted by aliveafter1000. FIXES: #1046 CLOSES: #1049 --- src/modules/partition/core/PartitionActions.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/modules/partition/core/PartitionActions.cpp b/src/modules/partition/core/PartitionActions.cpp index 458961d2f..fc4914696 100644 --- a/src/modules/partition/core/PartitionActions.cpp +++ b/src/modules/partition/core/PartitionActions.cpp @@ -223,7 +223,11 @@ doAutopartition( PartitionCoreModule* core, Device* dev, const QString& luksPass } PartitionInfo::setFormat( rootPartition, true ); PartitionInfo::setMountPoint( rootPartition, "/" ); - core->createPartition( dev, rootPartition ); + // Some buggy (legacy) BIOSes test if the bootflag of at least one partition is set. + // Otherwise they ignore the device in boot-order, so add it here. + core->createPartition( dev, rootPartition, + rootPartition->activeFlags() | ( isEfi ? PartitionTable::FlagNone : PartitionTable::FlagBoot ) + ); if ( shouldCreateSwap ) { From c522004575dce503acdf74abd97c8073376bd1a8 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 12 Nov 2018 15:26:15 +0100 Subject: [PATCH 5/7] [partition] Mount fs read-only when searching for fstab Submitted by aliveafter1000 FIXES: #1044 CLOSES: #1050 --- src/modules/partition/core/PartUtils.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/modules/partition/core/PartUtils.cpp b/src/modules/partition/core/PartUtils.cpp index e696a0569..b1b9ec9de 100644 --- a/src/modules/partition/core/PartUtils.cpp +++ b/src/modules/partition/core/PartUtils.cpp @@ -165,7 +165,7 @@ lookForFstabEntries( const QString& partitionPath ) QTemporaryDir mountsDir; mountsDir.setAutoRemove( false ); - int exit = QProcess::execute( "mount", { partitionPath, mountsDir.path() } ); + int exit = QProcess::execute( "mount", { "-o", "ro,noload", partitionPath, mountsDir.path() } ); if ( !exit ) // if all is well { QFile fstabFile( mountsDir.path() + "/etc/fstab" ); @@ -181,11 +181,7 @@ lookForFstabEntries( const QString& partitionPath ) } if ( QProcess::execute( "umount", { "-R", mountsDir.path() } ) ) - { cWarning() << "Could not unmount" << mountsDir.path(); - // There is stuff left in there, really don't remove - mountsDir.setAutoRemove( false ); - } } return fstabEntries; From e0ce500f365e5cdf972f101f757aa5ca8322bc28 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 12 Nov 2018 16:31:30 +0100 Subject: [PATCH 6/7] [partition] Improve debug-output after os-prober --- src/modules/partition/core/PartUtils.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/modules/partition/core/PartUtils.cpp b/src/modules/partition/core/PartUtils.cpp index b1b9ec9de..f50236eff 100644 --- a/src/modules/partition/core/PartUtils.cpp +++ b/src/modules/partition/core/PartUtils.cpp @@ -281,7 +281,6 @@ runOsprober( PartitionCoreModule* core ) osprober.readAllStandardOutput() ).trimmed() ); } - QString osProberReport( "Osprober lines, clean:\n" ); QStringList osproberCleanLines; OsproberEntryList osproberEntries; const auto lines = osproberOutput.split( '\n' ); @@ -313,8 +312,11 @@ runOsprober( PartitionCoreModule* core ) osproberCleanLines.append( line ); } } - osProberReport.append( osproberCleanLines.join( '\n' ) ); - cDebug() << osProberReport; + + if ( osproberCleanLines.count() > 0 ) + cDebug() << "os-prober lines after cleanup:" << Logger::DebugList( osproberCleanLines ); + else + cDebug() << "os-prober gave no output."; Calamares::JobQueue::instance()->globalStorage()->insert( "osproberLines", osproberCleanLines ); From 38d58fb6edfc6fb8dd453e5b1625e9a1314f2b4b Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 12 Nov 2018 17:07:18 +0100 Subject: [PATCH 7/7] [partition] Check for suitable FS before passing -o noload - The noload option prevents journal re-play (so it's an extra- strong read-only) but is only applicable to ext3 and ext4. Check the FS type before mounting; other FS types don't accept -o noload and will fail to mount. --- src/modules/partition/core/PartUtils.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/modules/partition/core/PartUtils.cpp b/src/modules/partition/core/PartUtils.cpp index f50236eff..7dddec414 100644 --- a/src/modules/partition/core/PartUtils.cpp +++ b/src/modules/partition/core/PartUtils.cpp @@ -31,6 +31,7 @@ #include #include +#include #include #include #include @@ -161,11 +162,26 @@ canBeResized( PartitionCoreModule* core, const QString& partitionPath ) static FstabEntryList lookForFstabEntries( const QString& partitionPath ) { + QStringList mountOptions{ "ro" }; + + auto r = CalamaresUtils::System::runCommand( + CalamaresUtils::System::RunLocation::RunInHost, + { "blkid", "-s", "TYPE", "-o", "value", partitionPath } + ); + if ( r.getExitCode() ) + cWarning() << "blkid on" << partitionPath << "failed."; + else + { + QString fstype = r.getOutput().trimmed(); + if ( ( fstype == "ext3" ) || ( fstype == "ext4" ) ) + mountOptions.append( "noload" ); + } + FstabEntryList fstabEntries; QTemporaryDir mountsDir; mountsDir.setAutoRemove( false ); - int exit = QProcess::execute( "mount", { "-o", "ro,noload", partitionPath, mountsDir.path() } ); + int exit = QProcess::execute( "mount", { "-o", mountOptions.join(','), partitionPath, mountsDir.path() } ); if ( !exit ) // if all is well { QFile fstabFile( mountsDir.path() + "/etc/fstab" );