1
0
mirror of https://github.com/rancher/os.git synced 2025-09-01 14:48:55 +00:00

/media and /mnt mounted as shared for console

This commit is contained in:
Darren Shepherd
2016-06-15 16:41:42 -07:00
parent c138ecb54d
commit 924e4b8aae
15 changed files with 68 additions and 2 deletions

View File

@@ -11,6 +11,7 @@ import (
"syscall"
log "github.com/Sirupsen/logrus"
"github.com/docker/docker/pkg/mount"
"github.com/rancher/docker-from-scratch"
"github.com/rancher/os/config"
"github.com/rancher/os/util"
@@ -180,6 +181,29 @@ func isInitrd() bool {
return int64(stat.Type) == TMPFS_MAGIC || int64(stat.Type) == RAMFS_MAGIC
}
func setupSharedRoot(c *config.CloudConfig) (*config.CloudConfig, error) {
if c.Rancher.NoSharedRoot {
return c, nil
}
if isInitrd() {
for _, i := range []string{"/mnt", "/media"} {
if err := os.Mkdir(i, 0755); err != nil {
return c, err
}
if err := mount.Mount("tmpfs", i, "tmpfs", "rw"); err != nil {
return c, err
}
if err := mount.MakeRShared(i); err != nil {
return c, err
}
}
return c, nil
}
return c, mount.MakeShared("/")
}
func RunInit() error {
os.Setenv("PATH", "/sbin:/usr/sbin:/usr/bin")
if isInitrd() {
@@ -223,6 +247,7 @@ func RunInit() error {
return c, nil
},
initializeSelinux,
setupSharedRoot,
sysInit,
}