long time no post

Preparing the next FluxFlux version I have integrated zram (successor of compcache) in linuxrc.
zram explained:
...creates a RAM based block device which acts as a swap disk, but is compressed and stored in memory instead of swap disk (which is slow), allowing very fast I/O and increasing the amount of memory available before the system starts swapping to disk.
Due to the fact that most netbooks today are memory constrained but have enough power to handle (de)compression
using zram is a perfect way ro increase the available virtual diskspace in live mode while using aufs.
On my test system (Atom Z520 with 2GB Ram) I could increase the ramsize in linuxrc from 60% to 80% while preserving
the same amount of available RAM while gaining 400MB more free diskspace. 8)
For those interested in here are the relevant parts from linuxrc/liblinuxlive.
liblinuxlive:
Code: Select all
...
# ==================================================================
# RAM compressing/optimizing function#s
# Author: Manfred Mueller, http://fluxflux.net
#
# Heavily based on zramswap-enabler from Sergey "Shnatsel" Davidoff,
# https://launchpad.net/~shnatsel
# ==================================================================
zram_start() {
# get the number of CPUs
num_cpus=$(cat /proc/cpuinfo | grep "cpu cores" | cut -d: -f2 | sed 's/ //g' | uniq)
# set decremented number of CPUs
decr_num_cpus=$(( $num_cpus - 1 ))
# get the amount of memory in the machine
mem_total_kb=$(grep MemTotal /proc/meminfo | rev | cut -d" " -f2 | rev)
mem_total=$((mem_total_kb * 1024))
# # determine modprobe parameter name, depending on kernel version
# if (uname --release | grep -E --silent "^3\.[123]"); then
# num_devices_parameter='zram_num_devices'
# else
# num_devices_parameter='num_devices'
# fi
# load zram modules
modprobe zram num_devices=$num_cpus
# initialize the devices, set total size to 1/2 RAM
for i in $(seq 0 $decr_num_cpus); do
echo $((mem_total / 2 / num_cpus)) > /sys/block/zram$i/disksize
done
# Creating swap filesystems
for i in $(seq 0 $decr_num_cpus); do
mkswap -L zram$i /dev/zram$i
done
# Switch the swaps on
for i in $(seq 0 $decr_num_cpus); do
swapon -p 100 /dev/zram$i
done
}
zram_stop() {
# Switching off swap
for i in $(grep -E --only-matching '/dev/zram[[:digit:]]+' /proc/swaps); do
swapoff $i
done
# remove module, wait instead of failing if it's busy
rmmod --wait zram
}
...
Code: Select all
...
# zram
if [ "$(cmdline_parameter zram)" != "" ]; then
if [ ! "$GERMAN_IS_ENABLED" ]; then
echolog "Using zram to increase usable RAM..."
else
echolog "Benutze zram zur Vergrößerung des nutzbaren Arbeitsspeichers..."
fi
fi
zram_start
...
RAMSIZE=$(cmdline_value ramsize)
if [ "$RAMSIZE" = "" ]; then
if [ ! "$(cmdline_parameter zram)" = "" ]; then
RAMSIZE="80%"
else
RAMSIZE="60%"
fi
fi
...
Code: Select all
...
# kill all processes which can be killed
killall_unneeded $(pidof cleanup)
# zram
if [ "$(cmdline_parameter zram)" != ""]; then
if [ ! "$GERMAN_IS_ENABLED" ]; then
echolog "disabling zram..."
else
echolog "Deaktiviere zram..."
fi
fi
zram_stop
...
Quax