mirror of https://github.com/hak5/openwrt.git
zram-swap: Shell cosmetic
Signed-off-by: Samuel Casa <samuel.casa@neratec.com>
(backported from 65e9561b3d
)
openwrt-18.06
parent
ac7c30708f
commit
afd6460418
|
@ -16,7 +16,7 @@ zram_size() # in megabytes
|
||||||
|
|
||||||
if [ -z "$zram_size" ]; then
|
if [ -z "$zram_size" ]; then
|
||||||
# e.g. 6mb for 16mb-routers or 61mb for 128mb-routers
|
# e.g. 6mb for 16mb-routers or 61mb for 128mb-routers
|
||||||
echo $(( $ram_size / 2048 ))
|
echo $(( ram_size / 2048 ))
|
||||||
else
|
else
|
||||||
echo "$zram_size"
|
echo "$zram_size"
|
||||||
fi
|
fi
|
||||||
|
@ -72,7 +72,7 @@ zram_reset()
|
||||||
list_cpu_idx()
|
list_cpu_idx()
|
||||||
{
|
{
|
||||||
# Offset by 1 if /dev/zram0 is in use by /tmp
|
# Offset by 1 if /dev/zram0 is in use by /tmp
|
||||||
if [ "$(mount | grep /dev/zram0)" ]; then
|
if mount | grep -q /dev/zram0; then
|
||||||
local line i=1
|
local line i=1
|
||||||
# Hot-add new ZRAM device (if necessary)
|
# Hot-add new ZRAM device (if necessary)
|
||||||
if [ ! -b /dev/zram1 ]; then
|
if [ ! -b /dev/zram1 ]; then
|
||||||
|
@ -86,7 +86,7 @@ list_cpu_idx()
|
||||||
case "$line" in
|
case "$line" in
|
||||||
[Pp]rocessor*)
|
[Pp]rocessor*)
|
||||||
echo $i
|
echo $i
|
||||||
i=$(( $i + 1 ))
|
i=$(( i + 1 ))
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
} done <"/proc/cpuinfo"
|
} done <"/proc/cpuinfo"
|
||||||
|
@ -107,7 +107,7 @@ start()
|
||||||
logger -s -t zram_start -p daemon.debug "activating '$zram_dev' for swapping ($zram_size MegaBytes)"
|
logger -s -t zram_start -p daemon.debug "activating '$zram_dev' for swapping ($zram_size MegaBytes)"
|
||||||
|
|
||||||
zram_reset "$zram_dev" "enforcing defaults"
|
zram_reset "$zram_dev" "enforcing defaults"
|
||||||
echo $(( $zram_size * 1024 * 1024 )) >"/sys/block/$( basename $zram_dev )/disksize"
|
echo $(( zram_size * 1024 * 1024 )) >"/sys/block/$( basename "$zram_dev" )/disksize"
|
||||||
mkswap "$zram_dev"
|
mkswap "$zram_dev"
|
||||||
swapon "$zram_dev"
|
swapon "$zram_dev"
|
||||||
} done
|
} done
|
||||||
|
|
Loading…
Reference in New Issue