To automate things, and since zram likes having the same number of ramdisks as CPU cores, I suggest a script like this (crappy, totally unprofessional) one be included somewhere in the next Salix release...
Code: Select all
# Number of CPU cores and bytes of physical memory num_cpus=`grep -c processor /proc/cpuinfo` mem_bytes=`free -b | grep Mem | tr -s " " | cut -f 2 -d " "` # individual disk size is half of MEM_BYTES, divided by NUM_CPUS zram_size=$(($mem_bytes / $num_cpus)) # Load zram and resize the disks modprobe zram num_devices=$num_cpus for i in /sys/block/zram*; do echo $zram_size > $i/disksize done # Create the swap spaces and start swapping for i in /dev/zram*; do mkswap $i swapon -p 32767 $i done
NB: I certainly don't suggest that anything like this be enabled by default... Just present in the install in case someone wants to run Salix on an old machine.
(Not that old machines with multiple cores are common, but who knows.)
Edit 05/17/2012: updated the script to be less brain damaged. Also note that, for 3.x kernels, you must use zram_num_devices rather than num_devices as the module parameter.
Edit 08/05/2012: modified the script so it doesn't bail out on computers with < 1 GB of memory. Duh!