zram: simplified totalmem calculation for zram.nix
This commit is contained in:
parent
a7ff459335
commit
5d3b1b84f5
@ -99,10 +99,8 @@ in
|
|||||||
set -u
|
set -u
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
PATH=${pkgs.procps}/bin:${pkgs.gnugrep}/bin:${pkgs.gnused}/bin
|
|
||||||
|
|
||||||
# Calculate memory to use for zram
|
# Calculate memory to use for zram
|
||||||
totalmem=$(free | grep -e "^Mem:" | sed -e 's/^Mem: *//' -e 's/ *.*//')
|
totalmem=$(${pkgs.gnugrep}/bin/grep 'MemTotal: ' /proc/meminfo | ${pkgs.gawk}/bin/awk '{print $2}')
|
||||||
mem=$(((totalmem * ${toString cfg.memoryPercent} / 100 / ${toString cfg.numDevices}) * 1024))
|
mem=$(((totalmem * ${toString cfg.memoryPercent} / 100 / ${toString cfg.numDevices}) * 1024))
|
||||||
|
|
||||||
echo $mem > /sys/class/block/${dev}/disksize
|
echo $mem > /sys/class/block/${dev}/disksize
|
||||||
|
Loading…
x
Reference in New Issue
Block a user