2018-09-16 04:55:26 +00:00
|
|
|
package sharedroot
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"github.com/rancher/os/config"
|
|
|
|
"github.com/rancher/os/pkg/init/fsmount"
|
2018-10-23 04:13:32 +00:00
|
|
|
|
|
|
|
"github.com/docker/docker/pkg/mount"
|
2018-09-16 04:55:26 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func Setup(c *config.CloudConfig) (*config.CloudConfig, error) {
|
|
|
|
if c.Rancher.NoSharedRoot {
|
|
|
|
return c, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
if fsmount.IsInitrd() {
|
|
|
|
for _, i := range []string{"/mnt", "/media", "/var/lib/system-docker"} {
|
|
|
|
if err := os.MkdirAll(i, 0755); err != nil {
|
|
|
|
return c, err
|
|
|
|
}
|
|
|
|
if err := mount.Mount("tmpfs", i, "tmpfs", "rw"); err != nil {
|
|
|
|
return c, err
|
|
|
|
}
|
|
|
|
if err := mount.MakeShared(i); err != nil {
|
|
|
|
return c, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return c, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return c, mount.MakeShared("/")
|
|
|
|
}
|