[openwrt/openwrt] zram-swap: default to lzo instead of lzo-rle compression

LEDE Commits lede-commits at lists.infradead.org
Thu Sep 17 04:29:46 EDT 2020


jow pushed a commit to openwrt/openwrt.git, branch master:
https://git.openwrt.org/419f149e482641ddc520f80a7ab2038f7e2ebc8a

commit 419f149e482641ddc520f80a7ab2038f7e2ebc8a
Author: Rui Salvaterra <rsalvaterra at gmail.com>
AuthorDate: Thu Jul 30 13:49:18 2020 +0100

    zram-swap: default to lzo instead of lzo-rle compression
    
    On devices with small amounts of RAM, zram-swap fails to initialise due to the
    default compression algorithm (lzo-rle). Startup example on an AirGrid M2, with
    32 MiB of RAM:
    
    root at airgrid:/etc/config# /etc/init.d/zram start
    zram_start: activating '/dev/zram0' for swapping (13 MegaBytes)
    zram_reset: enforcing defaults via /sys/block/zram0/reset
    sh: write error: Out of memory
    mkswap: image is too small
    swapon: /dev/zram0: Invalid argument
    root at airgrid:/etc/config#
    
    Fix this by defaulting to traditional lzo, which works fine and is always
    available.
    
    Signed-off-by: Rui Salvaterra <rsalvaterra at gmail.com>
---
 package/system/zram-swap/files/zram.init | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/package/system/zram-swap/files/zram.init b/package/system/zram-swap/files/zram.init
index 42c084855a..bfb9285600 100755
--- a/package/system/zram-swap/files/zram.init
+++ b/package/system/zram-swap/files/zram.init
@@ -85,8 +85,9 @@ zram_comp_algo()
 	local dev="$1"
 	local zram_comp_algo="$( uci -q get system. at system[0].zram_comp_algo )"
 
-	if [ -z "$zram_comp_algo" ] || [ ! -e /sys/block/$( basename $dev )/comp_algorithm ]; then
-		return 0
+	if [ -z "$zram_comp_algo" ]; then
+		# lzo-rle fails on small RAM devices, default to lzo, which is always available
+		zram_comp_algo="lzo"
 	fi
 
 	if [ $(grep -c "$zram_comp_algo" /sys/block/$( basename $dev )/comp_algorithm) -ne 0 ]; then



More information about the lede-commits mailing list