diff --git a/internal/utils/mounts.go b/internal/utils/mounts.go index a94949e..b6cde84 100644 --- a/internal/utils/mounts.go +++ b/internal/utils/mounts.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/containerd/containerd/mount" "github.com/deniswernert/go-fstab" + "github.com/kairos-io/kairos/sdk/state" "os" "strconv" "strings" @@ -233,3 +234,28 @@ func GetOverlayBase() string { return overlayConfig[1] } + +// GetOemLabel will ge the oem label to mount, first from the cmdline and if that fails, from the runtime +// This way users can override the oem label +func GetOemLabel() string { + var oemLabel string + // Pick both stanzas until we deprecate the cos ones + oemLabelCos := ReadCMDLineArg("rd.cos.oemlabel=") + oemLabelImmucore := ReadCMDLineArg("rd.immucore.oemlabel=") + if len(oemLabelCos) != 0 { + oemLabel = oemLabelCos[1] + } + if len(oemLabelImmucore) != 0 { + oemLabel = oemLabelImmucore[1] + } + + if oemLabel != "" { + return oemLabel + } + // We could not get it from the cmdline so get it from the runtime + runtime, err := state.NewRuntime() + if err != nil { + Log.Debug().Err(err).Msg("runtime") + } + return runtime.OEM.Label +} diff --git a/pkg/mount/dag_steps.go b/pkg/mount/dag_steps.go index 4306cb7..d4d4cf7 100644 --- a/pkg/mount/dag_steps.go +++ b/pkg/mount/dag_steps.go @@ -176,24 +176,18 @@ func (s *State) LoadEnvLayoutDagStep(g *herd.Graph, deps ...string) error { // MountOemDagStep will add mounting COS_OEM partition under s.Rootdir + /oem func (s *State) MountOemDagStep(g *herd.Graph, deps ...string) error { - runtime, err := state.NewRuntime() - if err != nil { - internalUtils.Log.Debug().Err(err).Msg("runtime") - } return g.Add(cnst.OpMountOEM, herd.WithDeps(deps...), herd.WithCallback( s.MountOP( - fmt.Sprintf("/dev/disk/by-label/%s", runtime.OEM.Label), + fmt.Sprintf("/dev/disk/by-label/%s", internalUtils.GetOemLabel()), s.path("/oem"), - runtime.OEM.Type, + internalUtils.DiskFSType(fmt.Sprintf("/dev/disk/by-label/%s", internalUtils.GetOemLabel())), []string{ "rw", "suid", "dev", "exec", - //"noauto", - //"nouser", "async", }, time.Duration(s.OemTimout)*time.Second), ),