From 32bd9efa11d2da06332468f5ed277f776340637f Mon Sep 17 00:00:00 2001 From: Alexis Svinartchouk Date: Fri, 23 Oct 2020 13:04:39 +0200 Subject: [PATCH] Change swap size on start if needed balenaOS now creates a /dev/zram0 device sized as min(25% of ram, 1G) which on EtcherPro is 256M. We need 1G, so we resize it on start if the amount is not 1G. Also modprobe is no longer necessary as zram is built into the kernel. Change-type: patch --- Dockerfile | 5 ----- docker-compose.yml | 1 - zram.sh | 9 ++++++--- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index a7fb4165..57e1a9de 100644 --- a/Dockerfile +++ b/Dockerfile @@ -44,11 +44,6 @@ WORKDIR /usr/src/app/node_modules/.bin RUN ln -s ../electron/cli.js electron WORKDIR /usr/src/app -RUN \ - apt-get update \ - && apt-get install -y kmod \ - && rm -rf /var/lib/apt/lists/* - CMD \ ./zram.sh \ && node /usr/src/app/update-config-and-start.js diff --git a/docker-compose.yml b/docker-compose.yml index 098f327c..7f4229b6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,7 +14,6 @@ services: labels: io.balena.features.dbus: 1 io.balena.features.supervisor-api: 1 - io.balena.features.kernel-modules: 1 volumes: - 'etcher_pki:/root/.pki' - 'etcher_cache:/root/.cache' diff --git a/zram.sh b/zram.sh index 3cddcce0..6a054978 100755 --- a/zram.sh +++ b/zram.sh @@ -1,10 +1,13 @@ #!/bin/bash DEVICE=/dev/zram0 +SIZE=1G -if [ ! -b $DEVICE ]; then - modprobe zram - zramctl $DEVICE --size 1024M +CURRENT_SIZE=$(zramctl --raw --noheadings --output DISKSIZE $DEVICE) + +if [ $CURRENT_SIZE != $SIZE ]; then + swapoff $DEVICE + zramctl $DEVICE --algorithm lz4 --size $SIZE mkswap $DEVICE swapon $DEVICE fi