diff options
author | Simon Rettberg | 2018-04-24 11:40:37 +0200 |
---|---|---|
committer | Simon Rettberg | 2018-04-24 11:40:37 +0200 |
commit | 89f7a9058dc1eb44d8387eaa98db9c74e1a06618 (patch) | |
tree | 82046f66b1c4fd17c3cb0bef765643a51ece1206 /core/rootfs/rootfs-stage32/data | |
parent | [rfs-stage32] zram swap: Use only one device on newer kernels (diff) | |
download | mltk-89f7a9058dc1eb44d8387eaa98db9c74e1a06618.tar.gz mltk-89f7a9058dc1eb44d8387eaa98db9c74e1a06618.tar.xz mltk-89f7a9058dc1eb44d8387eaa98db9c74e1a06618.zip |
[rfs-stage32] Increase min_free_kbytes for zram swap
Diffstat (limited to 'core/rootfs/rootfs-stage32/data')
-rwxr-xr-x | core/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-zram_swap | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/core/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-zram_swap b/core/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-zram_swap index 4a2cce6f..3cc5fe22 100755 --- a/core/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-zram_swap +++ b/core/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-zram_swap @@ -94,6 +94,16 @@ while [ "$NUM" -lt "$DEVS" ]; do fi done +# Increase min free memory so we have enough mem available when trying to move +# something to zram swap. We want 1%, or at least 64MiB +CURRENT=$(cat "/proc/sys/vm/min_free_kbytes") +TOTAL=$(awk '{ if ($1 == "MemTotal:") { print $2; exit } }' /proc/meminfo) +WANT=$(( TOTAL / 100 )) +[ "$WANT" -gt 65535 ] || WANT=65535 # minimum 64M +if [ "$CURRENT" -lt "$WANT" ]; then + echo "$WANT" > "/proc/sys/vm/min_free_kbytes" +fi + # Wait, so we don't trigger swap.target too early wait |