sharedroot.go 655 B

12345678910111213141516171819202122232425262728293031323334
  1. package sharedroot
  2. import (
  3. "os"
  4. "github.com/rancher/os/config"
  5. "github.com/rancher/os/pkg/init/fsmount"
  6. "github.com/docker/docker/pkg/mount"
  7. )
  8. func Setup(c *config.CloudConfig) (*config.CloudConfig, error) {
  9. if c.Rancher.NoSharedRoot {
  10. return c, nil
  11. }
  12. if fsmount.IsInitrd() {
  13. for _, i := range []string{"/mnt", "/media", "/var/lib/system-docker"} {
  14. if err := os.MkdirAll(i, 0755); err != nil {
  15. return c, err
  16. }
  17. if err := mount.Mount("tmpfs", i, "tmpfs", "rw"); err != nil {
  18. return c, err
  19. }
  20. if err := mount.MakeShared(i); err != nil {
  21. return c, err
  22. }
  23. }
  24. return c, nil
  25. }
  26. return c, mount.MakeShared("/")
  27. }