diff --git a/internal/utils/mounts.go b/internal/utils/mounts.go index 3249f6d..cf37212 100644 --- a/internal/utils/mounts.go +++ b/internal/utils/mounts.go @@ -260,5 +260,5 @@ func GetOemLabel() string { Log.Debug().Err(err).Msg("runtime") return "" } - return runtime.OEM.Label + return runtime.OEM.FilesystemLabel } diff --git a/pkg/mount/dag_live_media.go b/pkg/mount/dag_live_media.go index 57325d5..9cfa4be 100644 --- a/pkg/mount/dag_live_media.go +++ b/pkg/mount/dag_live_media.go @@ -14,8 +14,13 @@ func (s *State) RegisterLiveMedia(g *herd.Graph) error { // Waits for sysroot to be there, just in case s.LogIfError(s.WaitForSysrootDagStep(g), "Waiting for sysroot") // Run rootfs - s.LogIfError(s.RootfsStageDagStep(g, cnst.OpSentinel, cnst.OpWaitForSysroot), "rootfs stage") + + // Try to mount oem ONLY if we are on recovery squash + // The check to see if its enabled its on the DAG step itself + s.LogIfError(s.MountOemDagStep(g, cnst.OpWaitForSysroot), "oem mount") + + s.LogIfError(s.RootfsStageDagStep(g, herd.WithDeps(cnst.OpSentinel, cnst.OpWaitForSysroot), herd.WithWeakDeps(cnst.OpMountOEM)), "rootfs stage") // Run initramfs inside the /sysroot chroot! - s.LogIfError(s.InitramfsStageDagStep(g, herd.WithDeps(cnst.OpSentinel, cnst.OpWaitForSysroot, cnst.OpRootfsHook), herd.WithWeakDeps()), "initramfs stage") + s.LogIfError(s.InitramfsStageDagStep(g, herd.WithDeps(cnst.OpSentinel, cnst.OpWaitForSysroot, cnst.OpRootfsHook), herd.WithWeakDeps(cnst.OpMountOEM)), "initramfs stage") return err } diff --git a/pkg/mount/dag_normal_boot.go b/pkg/mount/dag_normal_boot.go index b96548f..34d9487 100644 --- a/pkg/mount/dag_normal_boot.go +++ b/pkg/mount/dag_normal_boot.go @@ -27,7 +27,7 @@ func (s *State) RegisterNormalBoot(g *herd.Graph) error { s.LogIfError(s.MountOemDagStep(g, cnst.OpMountRoot), "oem mount") // Run yip stage rootfs. Requires root+oem+sentinel to be mounted - s.LogIfError(s.RootfsStageDagStep(g, cnst.OpMountRoot, cnst.OpMountOEM, cnst.OpSentinel), "running rootfs stage") + s.LogIfError(s.RootfsStageDagStep(g, herd.WithDeps(cnst.OpMountRoot, cnst.OpMountOEM, cnst.OpSentinel)), "running rootfs stage") // Populate state bind mounts, overlay mounts, custom-mounts from /run/cos/cos-layout.env // Requires stage rootfs to have run, which usually creates the cos-layout.env file diff --git a/pkg/mount/dag_steps.go b/pkg/mount/dag_steps.go index bf0baad..1e31577 100644 --- a/pkg/mount/dag_steps.go +++ b/pkg/mount/dag_steps.go @@ -102,13 +102,13 @@ func (s *State) MountRootDagStep(g *herd.Graph) error { } // RootfsStageDagStep will add the rootfs stage. -func (s *State) RootfsStageDagStep(g *herd.Graph, deps ...string) error { - return g.Add(cnst.OpRootfsHook, herd.WithDeps(deps...), herd.WithCallback(s.RunStageOp("rootfs"))) +func (s *State) RootfsStageDagStep(g *herd.Graph, opts ...herd.OpOption) error { + return g.Add(cnst.OpRootfsHook, append(opts, herd.WithCallback(s.RunStageOp("rootfs")))...) } // InitramfsStageDagStep will add the rootfs stage. -func (s *State) InitramfsStageDagStep(g *herd.Graph, deps herd.OpOption, weakDeps herd.OpOption) error { - return g.Add(cnst.OpInitramfsHook, deps, weakDeps, herd.WithCallback(s.RunStageOp("initramfs"))) +func (s *State) InitramfsStageDagStep(g *herd.Graph, opts ...herd.OpOption) error { + return g.Add(cnst.OpInitramfsHook, append(opts, herd.WithCallback(s.RunStageOp("initramfs")))...) } // LoadEnvLayoutDagStep will add the stage to load from cos-layout.env and fill the proper CustomMounts, OverlayDirs and BindMounts. @@ -177,8 +177,14 @@ func (s *State) MountOemDagStep(g *herd.Graph, deps ...string) error { return g.Add(cnst.OpMountOEM, herd.WithDeps(deps...), herd.EnableIf(func() bool { - // Check if we can get the label. If we cant then we don't run this step - return internalUtils.GetOemLabel() != "" + runtime, _ := state.NewRuntime() + switch runtime.BootState { + // Don't run this on LiveCD/Netboot + case state.LiveCD: + return false + default: + return internalUtils.GetOemLabel() != "" + } }), herd.WithCallback( s.MountOP( diff --git a/pkg/mount/dag_uki_boot.go b/pkg/mount/dag_uki_boot.go index 46e6ddc..372d145 100644 --- a/pkg/mount/dag_uki_boot.go +++ b/pkg/mount/dag_uki_boot.go @@ -20,7 +20,7 @@ func (s *State) RegisterUKI(g *herd.Graph) error { s.LogIfError(s.UKIUdevDaemon(g), "udev") // Run rootfs stage - s.LogIfError(s.RootfsStageDagStep(g, cnst.OpSentinel, cnst.OpUkiUdev), "uki rootfs") + s.LogIfError(s.RootfsStageDagStep(g, herd.WithDeps(cnst.OpSentinel, cnst.OpUkiUdev)), "uki rootfs") // Remount root RO s.LogIfError(s.UKIRemountRootRODagStep(g), "remount root") @@ -43,7 +43,7 @@ func (s *State) RegisterUKI(g *herd.Graph) error { s.LogIfError(s.MountCustomBindsDagStep(g), "custom binds mount") // run initramfs stage - s.LogIfError(s.InitramfsStageDagStep(g, herd.WithDeps(cnst.OpMountBind), herd.WithWeakDeps()), "uki initramfs") + s.LogIfError(s.InitramfsStageDagStep(g, herd.WithDeps(cnst.OpMountBind)), "uki initramfs") s.LogIfError(g.Add(cnst.OpWriteFstab, herd.WithDeps(cnst.OpLoadConfig, cnst.OpCustomMounts, cnst.OpMountBind, cnst.OpOverlayMount), diff --git a/pkg/mount/state_test.go b/pkg/mount/state_test.go index 014bcc4..c5094b3 100644 --- a/pkg/mount/state_test.go +++ b/pkg/mount/state_test.go @@ -68,17 +68,19 @@ var _ = Describe("mounting immutable setup", func() { }) func checkLiveCDDag(dag [][]herd.GraphEntry, actualDag string) { - Expect(len(dag)).To(Equal(4), actualDag) + Expect(len(dag)).To(Equal(5), actualDag) Expect(len(dag[0])).To(Equal(1), actualDag) Expect(len(dag[1])).To(Equal(2), actualDag) Expect(len(dag[2])).To(Equal(1), actualDag) Expect(len(dag[3])).To(Equal(1), actualDag) + Expect(len(dag[4])).To(Equal(1), actualDag) Expect(dag[0][0].Name).To(Equal("init")) Expect(dag[1][0].Name).To(Or(Equal(cnst.OpSentinel), Equal(cnst.OpWaitForSysroot)), actualDag) Expect(dag[1][1].Name).To(Or(Equal(cnst.OpSentinel), Equal(cnst.OpWaitForSysroot)), actualDag) - Expect(dag[2][0].Name).To(Equal(cnst.OpRootfsHook), actualDag) - Expect(dag[3][0].Name).To(Equal(cnst.OpInitramfsHook), actualDag) + Expect(dag[2][0].Name).To(Equal(cnst.OpMountOEM), actualDag) + Expect(dag[3][0].Name).To(Equal(cnst.OpRootfsHook), actualDag) + Expect(dag[4][0].Name).To(Equal(cnst.OpInitramfsHook), actualDag) } func checkDag(dag [][]herd.GraphEntry, actualDag string) {