1
0
mirror of https://github.com/rancher/os.git synced 2025-08-31 14:23:11 +00:00

Support OEM partition and oem-config.yml

This commit is contained in:
Darren Shepherd
2015-12-19 22:26:09 -07:00
parent cd2829d220
commit 1a95080522
7 changed files with 79 additions and 9 deletions

View File

@@ -111,6 +111,19 @@ func mountState(cfg *config.CloudConfig) error {
return mountConfigured("state", cfg.Rancher.State.Dev, cfg.Rancher.State.FsType, STATE)
}
func mountOem(cfg *config.CloudConfig) (*config.CloudConfig, error) {
if cfg == nil {
var err error
if cfg, err = config.LoadConfig(); err != nil {
return cfg, err
}
}
if err := mountConfigured("oem", cfg.Rancher.State.OemDev, cfg.Rancher.State.OemFsType, config.OEM); err != nil {
log.Infof("Not mounting OEM: %v", err)
}
return cfg, nil
}
func tryMountState(cfg *config.CloudConfig) error {
if mountState(cfg) == nil {
return nil
@@ -132,8 +145,10 @@ func tryMountAndBootstrap(cfg *config.CloudConfig) (*config.CloudConfig, error)
}
log.Debugf("Switching to new root at %s %s", STATE, cfg.Rancher.State.Directory)
err := switchRoot(STATE, cfg.Rancher.State.Directory, cfg.Rancher.RmUsr)
return cfg, err
if err := switchRoot(STATE, cfg.Rancher.State.Directory, cfg.Rancher.RmUsr); err != nil {
return cfg, err
}
return mountOem(cfg)
}
func getLaunchConfig(cfg *config.CloudConfig, dockerCfg *config.DockerConfig) (*dockerlaunch.Config, []string) {
@@ -162,6 +177,7 @@ func RunInit() error {
func(c *config.CloudConfig) (*config.CloudConfig, error) {
return c, dockerlaunch.PrepareFs(&mountConfig)
},
mountOem,
func(_ *config.CloudConfig) (*config.CloudConfig, error) {
cfg, err := config.LoadConfig()
if err != nil {

View File

@@ -100,6 +100,10 @@ func copyMoveRoot(rootfs string, rmUsr bool) error {
}
func switchRoot(rootfs, subdir string, rmUsr bool) error {
if err := syscall.Unmount(config.OEM, 0); err != nil {
log.Debugf("Not umounting OEM: %v", err)
}
if subdir != "" {
fullRootfs := path.Join(rootfs, subdir)
if _, err := os.Stat(fullRootfs); os.IsNotExist(err) {