Skip to content

Commit b59a8b8

Browse files
authored
Merge pull request #5133 from afbjorklund/tmpfs
Move root filesystem from rootfs to tmpfs
2 parents 84b6e3d + eec1a06 commit b59a8b8

File tree

8 files changed

+38
-10
lines changed

8 files changed

+38
-10
lines changed

deploy/addons/gvisor/gvisor-config.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ oom_score = 0
3636
max_container_log_line_size = 16384
3737
[plugins.cri.containerd]
3838
snapshotter = "overlayfs"
39-
no_pivot = true
39+
no_pivot = false
4040
[plugins.cri.containerd.default_runtime]
4141
runtime_type = "io.containerd.runtime.v1.linux"
4242
runtime_engine = ""
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
mkdir /sysroot
3+
# the value 90% borrowed from tcl via boot2docker
4+
mount -t tmpfs -o size=90% tmpfs /sysroot
5+
# copy from rootfs, to be able to do switch_root(8)
6+
tar -C / --exclude=sysroot -cf - . | tar -C /sysroot/ -xf -
7+
8+
# devtmpfs does not get automounted for initramfs
9+
/bin/mount -t devtmpfs devtmpfs /sysroot/dev
10+
exec 0</sysroot/dev/console
11+
exec 1>/sysroot/dev/console
12+
exec 2>/sysroot/dev/console
13+
exec /sbin/switch_root /sysroot /sbin/init "$@"

deploy/iso/minikube-iso/package/containerd-bin/config.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ oom_score = 0
3636
max_container_log_line_size = 16384
3737
[plugins.cri.containerd]
3838
snapshotter = "overlayfs"
39-
no_pivot = true
39+
no_pivot = false
4040
[plugins.cri.containerd.default_runtime]
4141
runtime_type = "io.containerd.runtime.v1.linux"
4242
runtime_engine = ""

deploy/iso/minikube-iso/package/crio-bin/crio.conf

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ grpc_max_recv_msg_size = 16777216
9292
default_runtime = "runc"
9393

9494
# If true, the runtime will not use pivot_root, but instead use MS_MOVE.
95-
no_pivot = true
95+
no_pivot = false
9696

9797
# Path to the conmon binary, used for monitoring the OCI runtime.
9898
conmon = "/usr/libexec/crio/conmon"

deploy/iso/minikube-iso/package/podman/buildah.profile

-3
This file was deleted.

deploy/iso/minikube-iso/package/podman/libpod.conf

-2
This file was deleted.

deploy/iso/minikube-iso/package/podman/podman.mk

-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ endef
2929

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

3634
$(eval $(generic-package))

pkg/provision/buildroot.go

+22
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,13 @@ func (p *BuildrootProvisioner) GenerateDockerOptions(dockerPort int) (*provision
9292
driverNameLabel := fmt.Sprintf("provider=%s", p.Driver.DriverName())
9393
p.EngineOptions.Labels = append(p.EngineOptions.Labels, driverNameLabel)
9494

95+
noPivot := true
96+
// Using pivot_root is not supported on fstype rootfs
97+
if fstype, err := rootFileSystemType(p); err == nil {
98+
log.Debugf("root file system type: %s", fstype)
99+
noPivot = fstype == "rootfs"
100+
}
101+
95102
engineConfigTmpl := `[Unit]
96103
Description=Docker Application Container Engine
97104
Documentation=https://docs.docker.com
@@ -101,8 +108,15 @@ Requires= minikube-automount.service docker.socket
101108
[Service]
102109
Type=notify
103110
111+
`
112+
if noPivot {
113+
log.Warn("Using fundamentally insecure --no-pivot option")
114+
engineConfigTmpl += `
104115
# DOCKER_RAMDISK disables pivot_root in Docker, using MS_MOVE instead.
105116
Environment=DOCKER_RAMDISK=yes
117+
`
118+
}
119+
engineConfigTmpl += `
106120
{{range .EngineOptions.Env}}Environment={{.}}
107121
{{end}}
108122
@@ -160,6 +174,14 @@ WantedBy=multi-user.target
160174
}, nil
161175
}
162176

177+
func rootFileSystemType(p *BuildrootProvisioner) (string, error) {
178+
fs, err := p.SSHCommand("df --output=fstype / | tail -n 1")
179+
if err != nil {
180+
return "", err
181+
}
182+
return strings.TrimSpace(fs), nil
183+
}
184+
163185
// Package installs a package
164186
func (p *BuildrootProvisioner) Package(name string, action pkgaction.PackageAction) error {
165187
return nil

0 commit comments

Comments
 (0)