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:
25
init/init.go
25
init/init.go
@@ -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,
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user