Make zram and zswap mutually exclusive.
(TODO: document 'expert mode': how to get rid of zram on systems with fast storage)
This commit is contained in:
parent
4193dc0e37
commit
8e7ef752e3
@ -19,14 +19,14 @@
|
||||
# and script configuration
|
||||
. /usr/lib/armbian/armbian-common
|
||||
|
||||
# It's possible to override ZRAM_PERCENTAGE, ZRAM_MAX_DEVICES, SWAP_ALGORITHM,
|
||||
# RAMLOG_ALGORITHM and TMP_ALGORITHM here:
|
||||
# It's possible to override SWAP, ZRAM_PERCENTAGE, MEM_LIMIT_PERCENTAGE, ZRAM_MAX_DEVICES,
|
||||
# SWAP_ALGORITHM, RAMLOG_ALGORITHM, TMP_ALGORITHM and TMP_SIZE here:
|
||||
ENABLED=false
|
||||
[ -f /etc/default/armbian-zram-config ] && . /etc/default/armbian-zram-config
|
||||
# Exit if not Enabled
|
||||
[[ "$ENABLED" != "true" ]] && exit 0
|
||||
|
||||
# Do not interfere with already present config-zram package
|
||||
# Do not interfere with already present zram-config package
|
||||
dpkg -l | grep -q 'zram-config' && exit 0
|
||||
|
||||
activate_zram() {
|
||||
@ -56,12 +56,18 @@ activate_zram_swap() {
|
||||
# Return is SWAP is disabled (enabled by default)
|
||||
[[ -n "$SWAP" && "$SWAP" != "true" ]] && return;
|
||||
|
||||
# Disable zswap if zram should be used. To make use of zswap instead a
|
||||
# swap file or partition on *capable* storage needs to be chosen and
|
||||
# defined as swap and also in /etc/default/armbian-zram-config SWAP=false
|
||||
# needs to be set.
|
||||
echo 0 >/sys/module/zswap/parameters/enabled 2>/dev/null
|
||||
|
||||
# Limit Journal size to 20Mb
|
||||
sed -i "s/.*SystemMaxUse=$/SystemMaxUse=20M/" /etc/systemd/journald.conf
|
||||
|
||||
for (( i=1; i<=zram_devices; i++ )); do
|
||||
swap_device=$(zramctl -f |sed 's/\/dev\///')
|
||||
[[ ! ${swap_device} =~ ^zram ]] && echo -e "\n### No more available zram devices (${swap_device})\n" >>${Log} && exit 1;
|
||||
[[ ! ${swap_device} =~ ^zram ]] && echo -e "\n### No more available zram devices (${swap_device})\n" >>${Log} && exit 1;
|
||||
if [ -f /sys/block/${swap_device}/comp_algorithm ]; then
|
||||
# set compression algorithm, if defined as lzo choose lzo-rle if available
|
||||
# https://www.phoronix.com/scan.php?page=news_item&px=ZRAM-Linux-5.1-Better-Perform
|
||||
@ -91,8 +97,8 @@ activate_ramlog_partition() {
|
||||
ENABLED=$(awk -F"=" '/^ENABLED/ {print $2}' /etc/default/armbian-ramlog)
|
||||
[[ "$ENABLED" != "true" ]] && return
|
||||
log_device=$(zramctl -f |sed 's/\/dev\///')
|
||||
[[ ! ${log_device} =~ ^zram ]] && echo -e "\n### No more available zram devices (${log_device})\n" >>${Log} && exit 1;
|
||||
|
||||
[[ ! ${log_device} =~ ^zram ]] && echo -e "\n### No more available zram devices (${log_device})\n" >>${Log} && exit 1;
|
||||
|
||||
# read size also from /etc/default/armbian-ramlog
|
||||
ramlogsize=$(awk -F"=" '/^SIZE/ {print $2}' /etc/default/armbian-ramlog)
|
||||
disksize=$(sed -e 's/M$/*1048576/' -e 's/K$/*1024/' <<<${ramlogsize:=50M} | bc)
|
||||
@ -124,7 +130,7 @@ activate_compressed_tmp() {
|
||||
# create /tmp not as tmpfs but zram compressed if no fstab entry exists
|
||||
grep -q '^tmpfs /tmp' /etc/mtab && return
|
||||
tmp_device=$(zramctl -f |sed 's/\/dev\///')
|
||||
[[ ! ${tmp_device} =~ ^zram ]] && echo -e "\n### No more available zram devices (${tmp_device})\n" >>${Log} && exit 1;
|
||||
[[ ! ${tmp_device} =~ ^zram ]] && echo -e "\n### No more available zram devices (${tmp_device})\n" >>${Log} && exit 1;
|
||||
|
||||
if [[ -f /sys/block/${tmp_device}/comp_algorithm ]]; then
|
||||
if [ "X${TMP_ALGORITHM}" = "X" ]; then
|
||||
|
||||
Loading…
Reference in New Issue
Block a user