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
# Create the swap spaces and start swapping
for i in /dev/zram*; do
swapon -p 32767 $i
Assuming I did it right, this would create a number of ZRAM disks equal to the number of CPU cores, adding up to a maximum total of the entirety of physical memory. This should be okay, assuming you have any real swap space to fall back on.[/edit]
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!