Skip to content

Commit

Permalink
Merge pull request #5133 from afbjorklund/tmpfs
Browse files Browse the repository at this point in the history
Move root filesystem from rootfs to tmpfs
  • Loading branch information
tstromberg committed Aug 26, 2019
2 parents 84b6e3d + eec1a06 commit b59a8b8
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 10 deletions.
2 changes: 1 addition & 1 deletion deploy/addons/gvisor/gvisor-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ oom_score = 0
max_container_log_line_size = 16384
[plugins.cri.containerd]
snapshotter = "overlayfs"
no_pivot = true
no_pivot = false
[plugins.cri.containerd.default_runtime]
runtime_type = "io.containerd.runtime.v1.linux"
runtime_engine = ""
Expand Down
13 changes: 13 additions & 0 deletions deploy/iso/minikube-iso/board/coreos/minikube/rootfs-overlay/init
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh
mkdir /sysroot
# the value 90% borrowed from tcl via boot2docker
mount -t tmpfs -o size=90% tmpfs /sysroot
# copy from rootfs, to be able to do switch_root(8)
tar -C / --exclude=sysroot -cf - . | tar -C /sysroot/ -xf -

# devtmpfs does not get automounted for initramfs
/bin/mount -t devtmpfs devtmpfs /sysroot/dev
exec 0</sysroot/dev/console
exec 1>/sysroot/dev/console
exec 2>/sysroot/dev/console
exec /sbin/switch_root /sysroot /sbin/init "$@"
2 changes: 1 addition & 1 deletion deploy/iso/minikube-iso/package/containerd-bin/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ oom_score = 0
max_container_log_line_size = 16384
[plugins.cri.containerd]
snapshotter = "overlayfs"
no_pivot = true
no_pivot = false
[plugins.cri.containerd.default_runtime]
runtime_type = "io.containerd.runtime.v1.linux"
runtime_engine = ""
Expand Down
2 changes: 1 addition & 1 deletion deploy/iso/minikube-iso/package/crio-bin/crio.conf
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ grpc_max_recv_msg_size = 16777216
default_runtime = "runc"

# If true, the runtime will not use pivot_root, but instead use MS_MOVE.
no_pivot = true
no_pivot = false

# Path to the conmon binary, used for monitoring the OCI runtime.
conmon = "/usr/libexec/crio/conmon"
Expand Down
3 changes: 0 additions & 3 deletions deploy/iso/minikube-iso/package/podman/buildah.profile

This file was deleted.

2 changes: 0 additions & 2 deletions deploy/iso/minikube-iso/package/podman/libpod.conf

This file was deleted.

2 changes: 0 additions & 2 deletions deploy/iso/minikube-iso/package/podman/podman.mk
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ endef

define PODMAN_INSTALL_TARGET_CMDS
$(INSTALL) -Dm755 $(@D)/bin/podman $(TARGET_DIR)/usr/bin/podman
$(INSTALL) -Dm644 $(BR2_EXTERNAL_MINIKUBE_PATH)/package/podman/libpod.conf $(TARGET_DIR)/etc/containers/libpod.conf
$(INSTALL) -Dm644 $(BR2_EXTERNAL_MINIKUBE_PATH)/package/podman/buildah.profile $(TARGET_DIR)/etc/profile.d/podman.sh
endef

$(eval $(generic-package))
22 changes: 22 additions & 0 deletions pkg/provision/buildroot.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ func (p *BuildrootProvisioner) GenerateDockerOptions(dockerPort int) (*provision
driverNameLabel := fmt.Sprintf("provider=%s", p.Driver.DriverName())
p.EngineOptions.Labels = append(p.EngineOptions.Labels, driverNameLabel)

noPivot := true
// Using pivot_root is not supported on fstype rootfs
if fstype, err := rootFileSystemType(p); err == nil {
log.Debugf("root file system type: %s", fstype)
noPivot = fstype == "rootfs"
}

engineConfigTmpl := `[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
Expand All @@ -101,8 +108,15 @@ Requires= minikube-automount.service docker.socket
[Service]
Type=notify
`
if noPivot {
log.Warn("Using fundamentally insecure --no-pivot option")
engineConfigTmpl += `
# DOCKER_RAMDISK disables pivot_root in Docker, using MS_MOVE instead.
Environment=DOCKER_RAMDISK=yes
`
}
engineConfigTmpl += `
{{range .EngineOptions.Env}}Environment={{.}}
{{end}}
Expand Down Expand Up @@ -160,6 +174,14 @@ WantedBy=multi-user.target
}, nil
}

func rootFileSystemType(p *BuildrootProvisioner) (string, error) {
fs, err := p.SSHCommand("df --output=fstype / | tail -n 1")
if err != nil {
return "", err
}
return strings.TrimSpace(fs), nil
}

// Package installs a package
func (p *BuildrootProvisioner) Package(name string, action pkgaction.PackageAction) error {
return nil
Expand Down

0 comments on commit b59a8b8

Please sign in to comment.