Skip to content

Commit

Permalink
zram-swap: set the zram swap priority to 100 by default
Browse files Browse the repository at this point in the history
New swap devices are added in decreasing priority order, starting at -1. Make
sure the zram swap device has the highest priority, by default.

Signed-off-by: Rui Salvaterra <rsalvaterra@gmail.com>
  • Loading branch information
rsalvaterra authored and aparcar committed Jun 28, 2021
1 parent f727005 commit 7720de4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions package/system/zram-swap/files/zram.init
Expand Up @@ -144,15 +144,18 @@ start()

local zram_size="$( zram_getsize )"
local zram_priority="$( uci -q get system.@system[0].zram_priority )"
zram_priority=${zram_priority:+-p $zram_priority}

if [ -z "$zram_priority" ]; then
zram_priority="100"
fi

logger -s -t zram_start -p daemon.debug "activating '$zram_dev' for swapping ($zram_size MegaBytes)"

zram_reset "$zram_dev" "enforcing defaults"
zram_comp_algo "$zram_dev"
echo $(( $zram_size * 1024 * 1024 )) >"/sys/block/$( basename "$zram_dev" )/disksize"
busybox mkswap "$zram_dev"
busybox swapon -d $zram_priority "$zram_dev"
busybox swapon -d -p $zram_priority "$zram_dev"
}

stop()
Expand Down

0 comments on commit 7720de4

Please sign in to comment.