mirror of
https://github.com/openwrt/openwrt.git
synced 2025-01-21 03:55:06 +00:00
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@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@airgrid:/etc/config# Fix this by defaulting to traditional lzo, which works fine and is always available. Signed-off-by: Rui Salvaterra <rsalvaterra@gmail.com>
This commit is contained in:
parent
0fbdb51f76
commit
419f149e48
@ -85,8 +85,9 @@ zram_comp_algo()
|
|||||||
local dev="$1"
|
local dev="$1"
|
||||||
local zram_comp_algo="$( uci -q get system.@system[0].zram_comp_algo )"
|
local zram_comp_algo="$( uci -q get system.@system[0].zram_comp_algo )"
|
||||||
|
|
||||||
if [ -z "$zram_comp_algo" ] || [ ! -e /sys/block/$( basename $dev )/comp_algorithm ]; then
|
if [ -z "$zram_comp_algo" ]; then
|
||||||
return 0
|
# lzo-rle fails on small RAM devices, default to lzo, which is always available
|
||||||
|
zram_comp_algo="lzo"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $(grep -c "$zram_comp_algo" /sys/block/$( basename $dev )/comp_algorithm) -ne 0 ]; then
|
if [ $(grep -c "$zram_comp_algo" /sys/block/$( basename $dev )/comp_algorithm) -ne 0 ]; then
|
||||||
|
Loading…
Reference in New Issue
Block a user