Add shim to choose next entry to boot from (#230)

This commit is contained in:
Itxaka
2024-02-21 10:44:32 +01:00
committed by GitHub
parent cce432133e
commit 2e9c85e63a
13 changed files with 775 additions and 19 deletions

View File

@@ -27,6 +27,7 @@ import (
"github.com/jaypipes/ghw/pkg/context"
"github.com/jaypipes/ghw/pkg/linuxpath"
ghwUtil "github.com/jaypipes/ghw/pkg/util"
"github.com/kairos-io/kairos-agent/v2/pkg/constants"
v1 "github.com/kairos-io/kairos-agent/v2/pkg/types/v1"
log "github.com/sirupsen/logrus"
)
@@ -209,3 +210,22 @@ func GetPartitionViaDM(fs v1.FS, label string) *v1.Partition {
}
return part
}
// GetEfiPartition returns the EFI partition by looking for the partition with the label "COS_GRUB"
func GetEfiPartition() (*v1.Partition, error) {
var efiPartition *v1.Partition
parts, err := GetAllPartitions()
if err != nil {
return efiPartition, fmt.Errorf("could not read host partitions")
}
for _, p := range parts {
if p.FilesystemLabel == constants.EfiLabel {
efiPartition = p
break
}
}
if efiPartition == nil {
return efiPartition, fmt.Errorf("could not find EFI partition")
}
return efiPartition, nil
}