Skip to content

Commit

Permalink
Do not remount State partition unneccesarily
Browse files Browse the repository at this point in the history
Signed-off-by: Andrea Mazzotti <andrea.mazzotti@suse.com>
  • Loading branch information
anmazzotti committed Feb 29, 2024
1 parent b9a3b61 commit 6b53b19
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions pkg/action/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,19 @@ func (u *UpgradeAction) mountRWPartitions(cleanup *utils.CleanStack) error {
}
cleanup.Push(umount)

umount, err = elemental.MountRWPartition(u.cfg.Config, u.spec.Partitions.State)
if err != nil {
return elementalError.NewFromError(err, elementalError.MountStatePartition)
if !elemental.IsRecoveryMode(u.cfg.Config) {
umount, err = elemental.MountRWPartition(u.cfg.Config, u.spec.Partitions.Recovery)
if err != nil {
return elementalError.NewFromError(err, elementalError.MountRecoveryPartition)
}
cleanup.Push(umount)
} else {
umount, err = elemental.MountRWPartition(u.cfg.Config, u.spec.Partitions.State)
if err != nil {
return elementalError.NewFromError(err, elementalError.MountStatePartition)
}
cleanup.Push(umount)
}
cleanup.Push(umount)

if u.spec.Partitions.Persistent != nil {
umount, err = elemental.MountRWPartition(u.cfg.Config, u.spec.Partitions.Persistent)
Expand All @@ -225,12 +233,6 @@ func (u *UpgradeAction) mountRWPartitions(cleanup *utils.CleanStack) error {
cleanup.Push(umount)
}

umount, err = elemental.MountRWPartition(u.cfg.Config, u.spec.Partitions.Recovery)
if err != nil {
return elementalError.NewFromError(err, elementalError.MountRecoveryPartition)
}
cleanup.Push(umount)

return nil
}

Expand Down

0 comments on commit 6b53b19

Please sign in to comment.