diff --git a/zramswapoff b/zramswapoff index 552a27a..271222f 100644 --- a/zramswapoff +++ b/zramswapoff @@ -1,16 +1,6 @@ #!/bin/bash -# get the number of CPUs -num_cpus=$(grep -c processor /proc/cpuinfo) - -# set decremented number of CPUs -decr_num_cpus=$((num_cpus - 1)) - # Switching off swap -for i in $(seq 0 $decr_num_cpus); do -if [ "$(grep /dev/zram$i /proc/swaps)" != "" ]; then -swapoff /dev/zram$i -fi -done +swapoff /dev/zram0 rmmod zram diff --git a/zramswapon b/zramswapon index 399a28d..09496b5 100644 --- a/zramswapon +++ b/zramswapon @@ -1,34 +1,18 @@ #!/bin/bash -# get the number of CPUs -num_cpus=$(grep -c processor /proc/cpuinfo) -# if something goes wrong, assume we have 1 -[ "$num_cpus" != 0 ] || num_cpus=1 - -# set decremented number of CPUs -decr_num_cpus=$((num_cpus - 1)) - # get the amount of memory in the machine mem_total_kb=$(grep MemTotal /proc/meminfo | grep -E --only-matching '[[:digit:]]+') mem_total=$((mem_total_kb * 1024)) -# load dependency modules -#modprobe zram zram_num_devices=$num_cpus -# Determine module parm -mod_parm=$(modinfo zram |grep parm |tr -s " " |cut -f2 -d ":") -modprobe zram $mod_parm=$num_cpus +# load the dependency module +modprobe zram -# initialize the devices -for i in $(seq 0 $decr_num_cpus); do -echo $((mem_total / num_cpus)) > /sys/block/zram$i/disksize -done +# initialize the device with zstd compression algorithm +echo zstd > /sys/block/zram0/comp_algorithm; +echo $mem_total > /sys/block/zram0/disksize -# Creating swap filesystems -for i in $(seq 0 $decr_num_cpus); do -mkswap /dev/zram$i -done +# Creating the swap filesystem +mkswap /dev/zram0 # Switch the swaps on -for i in $(seq 0 $decr_num_cpus); do -swapon -p 100 /dev/zram$i -done +swapon -p 100 /dev/zram0