#!/bin/bash
. /etc/rc.conf
. /etc/rc.d/functions
# get the number of CPUsnum_cpus=$(grep -c processor /proc/cpuinfo)# if something goes wrong, assume we have 1[["$num_cpus" != 0 ]]||num_cpus=1
# set decremented number of CPUsdecr_num_cpus=$((num_cpus -1))case"1ドル" in
start)
stat_busy "Enabling zram-based swap"# get the amount of memory in the machinemem_total_kb=$(grep MemTotal /proc/meminfo | grep -E --only-matching '[[:digit:]]+')mem_total=$((mem_total_kb *1024))# load dependency modules
modprobe zram num_devices=$num_cpus# initialize the devicesfor i in $(seq 0 $decr_num_cpus); doecho$((mem_total / num_cpus)) > /sys/block/zram$i/disksize
done# Creating swap filesystemsfor i in $(seq 0 $decr_num_cpus); do
mkswap /dev/zram$idone# Switch the swaps onfor i in $(seq 0 $decr_num_cpus); do
swapon -p 100 /dev/zram$idone
stat_done
;;
stop)
stat_busy "Switching off zram-based swap"# Switching off swapfor i in $(seq 0 $decr_num_cpus); do if[["$(grep /dev/zram$i /proc/swaps)" !=""]]; then
swapoff /dev/zram$ifi done
rmmod zram
stat_done
;;
*)echo"usage: 0ドル {start|stop}"esacexit 0
[^] # Re: tmpfs
Posté par Nonolapéro . En réponse au journal Améliorer vos ordinateurs avec zRam !. Évalué à 2.
Je viens de croiser ceci : http://www.webupd8.org/2011/10/increased-performance-in-linux-with.html
Voici le script adapté pour archlinux (https://aur.archlinux.org/packages.php?ID=52958) je ne sais pas si ça te sera utile mais je copie ici.