Symlink /sysroot/oem to /oem so we can run rootfs stage

Looks like we need to have the oem partition loaded for some cases, and
during rootfs we should pick it up.

Currently we only mount it under /sysroot/oem. IIRC in
cos-immutable-rootfs it was mounted under /oem directly, the rootfs
stage service run and then when cos-layout was launched it made sure to
unmount /oem so it could mount it under /sysroot/oem

In our case its a bit more complicated, we may need to mount it under
/oem before the rootfs run, then unmount it and mount it in the proper
place. Im hoping we can get away with just creating the symlink

Signed-off-by: Itxaka <itxaka.garcia@spectrocloud.com>
This commit is contained in:
Itxaka
2023-02-14 09:48:44 +01:00
parent 076bba95dc
commit 2aee7ab5a0
2 changed files with 12 additions and 1 deletions

View File

@@ -59,7 +59,11 @@ Sends a generic event payload with the configuration found in the scanned direct
img := utils.ReadCMDLineArg("cos-img/filename=") img := utils.ReadCMDLineArg("cos-img/filename=")
if len(img) == 0 { if len(img) == 0 {
log.Logger.Fatal().Msg("Could not get the image name from cmdline (i.e. cos-img/filename=/cOS/active.img)") if c.Bool("dry-run") {
img = []string{"fake"}
} else {
log.Logger.Fatal().Msg("Could not get the image name from cmdline (i.e. cos-img/filename=/cOS/active.img)")
}
} }
log.Debug().Strs("TargetImage", img).Msg("Target image") log.Debug().Strs("TargetImage", img).Msg("Target image")
g := herd.DAG() g := herd.DAG()

View File

@@ -92,6 +92,13 @@ func (s *State) RunStageOp(stage string) func(context.Context) error {
return err return err
} }
} }
if _, err := os.Stat("/oem"); os.IsNotExist(err) {
err = os.Symlink("/sysroot/oem", "/oem")
if err != nil {
s.Logger.Err(err).Msg("creating symlink")
return err
}
}
} }
cmd := fmt.Sprintf("elemental run-stage %s", stage) cmd := fmt.Sprintf("elemental run-stage %s", stage)