Adjust size to take into account upgrades (#130)

This commit is contained in:
Itxaka
2023-08-18 12:18:10 +02:00
committed by GitHub
parent dffef50ca0
commit 28dd23c4f4
2 changed files with 9 additions and 4 deletions

View File

@@ -153,6 +153,9 @@ func (u *UpgradeAction) Run() (err error) {
cleanup.Push(func() error { return u.remove(upgradeImg.File) }) cleanup.Push(func() error { return u.remove(upgradeImg.File) })
// Recovery does not mount persistent, so try to mount it. Ignore errors, as it's not mandatory. // Recovery does not mount persistent, so try to mount it. Ignore errors, as it's not mandatory.
// This was used by luet extraction IIRC to not exhaust the /tmp dir
// Not sure if its on use anymore and we should drop it
// TODO: Check if we really need persistent mounted here
persistentPart := u.spec.Partitions.Persistent persistentPart := u.spec.Partitions.Persistent
if persistentPart != nil { if persistentPart != nil {
// Create the dir otherwise the check for mounted dir fails // Create the dir otherwise the check for mounted dir fails
@@ -162,8 +165,6 @@ func (u *UpgradeAction) Run() (err error) {
umount, err = e.MountRWPartition(persistentPart) umount, err = e.MountRWPartition(persistentPart)
if err != nil { if err != nil {
u.config.Logger.Warn("could not mount persistent partition: %s", err.Error()) u.config.Logger.Warn("could not mount persistent partition: %s", err.Error())
} else {
cleanup.Push(umount)
} }
} }
} }

View File

@@ -125,9 +125,11 @@ func NewInstallElementalPartitions(spec *v1.InstallSpec) v1.ElementalPartitions
Flags: []string{}, Flags: []string{},
} }
// Double the space for recovery, as upgrades use the recovery partition to create the transition image for upgrades
// so we need twice the space to do a proper upgrade
pt.Recovery = &v1.Partition{ pt.Recovery = &v1.Partition{
FilesystemLabel: constants.RecoveryLabel, FilesystemLabel: constants.RecoveryLabel,
Size: spec.Recovery.Size + 200, Size: (spec.Recovery.Size * 2) + 200,
Name: constants.RecoveryPartName, Name: constants.RecoveryPartName,
FS: constants.LinuxFs, FS: constants.LinuxFs,
MountPoint: constants.RecoveryDir, MountPoint: constants.RecoveryDir,
@@ -136,9 +138,11 @@ func NewInstallElementalPartitions(spec *v1.InstallSpec) v1.ElementalPartitions
// Add 1 Gb to the partition so images can grow a bit, otherwise you are stuck with the smallest space possible and // Add 1 Gb to the partition so images can grow a bit, otherwise you are stuck with the smallest space possible and
// there is no coming back from that // there is no coming back from that
// Also multiply the space for active, as upgrades use the state partition to create the transition image for upgrades
// so we need twice the space to do a proper upgrade
pt.State = &v1.Partition{ pt.State = &v1.Partition{
FilesystemLabel: constants.StateLabel, FilesystemLabel: constants.StateLabel,
Size: spec.Active.Size + spec.Passive.Size + 1000, Size: (spec.Active.Size * 2) + spec.Passive.Size + 1000,
Name: constants.StatePartName, Name: constants.StatePartName,
FS: constants.LinuxFs, FS: constants.LinuxFs,
MountPoint: constants.StateDir, MountPoint: constants.StateDir,