mirror of
https://github.com/kairos-io/kairos-agent.git
synced 2025-08-10 12:41:56 +00:00
Mount EFI partition as RW, to rotate recovery -> active on reset
Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
This commit is contained in:
parent
a635a7ba08
commit
ca84f82faa
@ -523,12 +523,27 @@ func NewUkiResetSpec(cfg *Config) (spec *v1.ResetUkiSpec, err error) {
|
|||||||
spec.Partitions.Persistent = partitions.GetPartitionViaDM(cfg.Fs, constants.PersistentLabel)
|
spec.Partitions.Persistent = partitions.GetPartitionViaDM(cfg.Fs, constants.PersistentLabel)
|
||||||
spec.Partitions.OEM = partitions.GetPartitionViaDM(cfg.Fs, constants.OEMLabel)
|
spec.Partitions.OEM = partitions.GetPartitionViaDM(cfg.Fs, constants.OEMLabel)
|
||||||
|
|
||||||
|
// Get EFI partition
|
||||||
|
parts, err := partitions.GetAllPartitions()
|
||||||
|
if err != nil {
|
||||||
|
return spec, fmt.Errorf("could not read host partitions")
|
||||||
|
}
|
||||||
|
for _, p := range parts {
|
||||||
|
if p.FilesystemLabel == constants.EfiLabel {
|
||||||
|
spec.Partitions.EFI = p
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if spec.Partitions.Persistent == nil {
|
if spec.Partitions.Persistent == nil {
|
||||||
return spec, fmt.Errorf("persistent partition not found")
|
return spec, fmt.Errorf("persistent partition not found")
|
||||||
}
|
}
|
||||||
if spec.Partitions.OEM == nil {
|
if spec.Partitions.OEM == nil {
|
||||||
return spec, fmt.Errorf("oem partition not found")
|
return spec, fmt.Errorf("oem partition not found")
|
||||||
}
|
}
|
||||||
|
if spec.Partitions.EFI == nil {
|
||||||
|
return spec, fmt.Errorf("efi partition not found")
|
||||||
|
}
|
||||||
|
|
||||||
// Fill oem partition
|
// Fill oem partition
|
||||||
err = unmarshallFullSpec(cfg, "reset", spec)
|
err = unmarshallFullSpec(cfg, "reset", spec)
|
||||||
|
@ -58,6 +58,13 @@ func (r *ResetAction) Run() (err error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// REMOUNT /efi as RW (its RO by default)
|
||||||
|
umount, err := e.MountRWPartition(r.spec.Partitions.EFI)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
cleanup.Push(umount)
|
||||||
|
|
||||||
// Copy "recovery" to "active"
|
// Copy "recovery" to "active"
|
||||||
err = overwriteArtifactSetRole(r.cfg.Fs, constants.UkiEfiDir, "recovery", "active", r.cfg.Logger)
|
err = overwriteArtifactSetRole(r.cfg.Fs, constants.UkiEfiDir, "recovery", "active", r.cfg.Logger)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user