zram-swap: set the zram swap priority to 100 by default
authorRui Salvaterra <rsalvaterra@gmail.com>
Thu, 24 Jun 2021 19:05:22 +0000 (20:05 +0100)
committerPaul Spooren <mail@aparcar.org>
Mon, 28 Jun 2021 00:44:28 +0000 (14:44 -1000)
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>
package/system/zram-swap/files/zram.init

index 9fce5e4797048f73a42a1f98d2cdf915d89319de..ea9b55680e8f2856168a464049f7bdb1caa51b75 100755 (executable)
@@ -144,7 +144,10 @@ 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)"
 
@@ -152,7 +155,7 @@ start()
        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()