Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Calamares
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
osak
Calamares
Commits
c987235b
Commit
c987235b
authored
10 years ago
by
Teo Mrnjavac
Browse files
Options
Downloads
Patches
Plain Diff
Scan for type 82 partitions and clear them regardless of swapon status.
parent
91cf3950
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/modules/partition/jobs/ClearMountsJob.cpp
+46
-7
46 additions, 7 deletions
src/modules/partition/jobs/ClearMountsJob.cpp
src/modules/partition/jobs/ClearMountsJob.h
+1
-0
1 addition, 0 deletions
src/modules/partition/jobs/ClearMountsJob.h
with
47 additions
and
7 deletions
src/modules/partition/jobs/ClearMountsJob.cpp
+
46
−
7
View file @
c987235b
...
...
@@ -72,6 +72,31 @@ ClearMountsJob::exec()
QString
partitions
=
process
.
readAllStandardOutput
();
QStringList
partitionsList
=
partitions
.
simplified
().
split
(
' '
);
// Build a list of partitions of type 82 (Linux swap / Solaris).
// We then need to clear them just in case they contain something resumable from a
// previous suspend-to-disk.
QStringList
swapPartitions
;
process
.
start
(
"sfdisk"
,
{
"-d"
,
m_device
->
deviceNode
()
}
);
process
.
waitForFinished
();
// Sample output:
// % sudo sfdisk -d /dev/sda
// label: dos
// label-id: 0x000ced89
// device: /dev/sda
// unit: sectors
// /dev/sda1 : start= 63, size= 29329345, type=83, bootable
// /dev/sda2 : start= 29331456, size= 2125824, type=82
swapPartitions
=
QString
::
fromLocal8Bit
(
process
.
readAllStandardOutput
()
)
.
split
(
'\n'
);
swapPartitions
=
swapPartitions
.
filter
(
"type=82"
);
for
(
QStringList
::
iterator
it
=
swapPartitions
.
begin
();
it
!=
swapPartitions
.
end
();
++
it
)
{
*
it
=
(
*
it
).
simplified
().
split
(
' '
).
first
();
}
// First we umount all LVM logical volumes we can find
process
.
start
(
"lvscan"
,
{
"-a"
}
);
process
.
waitForFinished
();
...
...
@@ -133,6 +158,13 @@ ClearMountsJob::exec()
goodNews
.
append
(
news
);
}
foreach
(
QString
p
,
swapPartitions
)
{
QString
news
=
tryClearSwap
(
p
);
if
(
!
news
.
isEmpty
()
)
goodNews
.
append
(
news
);
}
Calamares
::
JobResult
ok
=
Calamares
::
JobResult
::
ok
();
ok
.
setMessage
(
tr
(
"Cleared all mounts for %1"
)
.
arg
(
m_device
->
deviceNode
()
)
);
...
...
@@ -156,13 +188,20 @@ ClearMountsJob::tryUmount( const QString& partPath )
process
.
start
(
"swapoff"
,
{
partPath
}
);
process
.
waitForFinished
();
if
(
process
.
exitCode
()
==
0
)
return
QString
(
"Successfully disabled swap %1."
).
arg
(
partPath
);
return
QString
();
}
QString
ClearMountsJob
::
tryClearSwap
(
const
QString
&
partPath
)
{
QProcess
process
;
process
.
start
(
"mkswap"
,
{
partPath
}
);
process
.
waitForFinished
();
if
(
process
.
exitCode
()
==
0
)
return
QString
(
"Successfully disabled and cleared swap %1."
).
arg
(
partPath
);
return
QString
(
"Successfully disabled but not cleared swap %1."
).
arg
(
partPath
);
}
return
QString
(
"Successfully cleared swap %1."
).
arg
(
partPath
);
return
QString
();
}
This diff is collapsed.
Click to expand it.
src/modules/partition/jobs/ClearMountsJob.h
+
1
−
0
View file @
c987235b
...
...
@@ -37,6 +37,7 @@ public:
Calamares
::
JobResult
exec
()
override
;
private:
QString
tryUmount
(
const
QString
&
partPath
);
QString
tryClearSwap
(
const
QString
&
partPath
);
Device
*
m_device
;
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment