Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=frugalware-current.git;a=commitdiff;h=1faa80d439709543a6cc0286a0d26159b6447d5c
commit 1faa80d439709543a6cc0286a0d26159b6447d5c Author: Devil505 <devil505li...@gmail.com> Date: Mon Oct 24 18:14:20 2011 +0200 zramswap-enabler-20111020-1-i686 * new package diff --git a/source/apps-extra/zramswap-enabler/FrugalBuild b/source/apps-extra/zramswap-enabler/FrugalBuild new file mode 100644 index 0000000..3fdc9ce --- /dev/null +++ b/source/apps-extra/zramswap-enabler/FrugalBuild @@ -0,0 +1,25 @@ +# Compiling Time: 0.01 SBU +# Maintainer: Devil505 <devil505li...@gmail.com> + +pkgname=zramswap-enabler +pkgver=20111020 +pkgrel=1 +pkgdesc="Sets up zram swap devices on boot" +url="https://github.com/mystilleef/FedoraZram" +depends=() +groups=('apps-extra') +archs=('i686' 'x86_64') +up2date=$pkgver +source=(zramstart zramstop zram.service) +sha1sums=('95b41af144744e75b8734efa3d18fdfa4c006395' \ + '531ea30ab1906f9290e8e49b22991763f9b02a64' \ + 'f0174e59e813f7b180096e415ae64adb5fe662df') + +build() { + Fmkdir usr/bin + Fexe zramstart usr/bin/ + Fexe zramstop usr/bin/ + Fmkdir lib/systemd/system/ + Finstall 0644 zram.service /lib/systemd/system/zram.service +} + diff --git a/source/apps-extra/zramswap-enabler/zram.service b/source/apps-extra/zramswap-enabler/zram.service new file mode 100755 index 0000000..fe91fd5 --- /dev/null +++ b/source/apps-extra/zramswap-enabler/zram.service @@ -0,0 +1,12 @@ +[Unit] +Description=Enable compressed swap in memory using zram +After=multi-user.target + +[Service] +RemainAfterExit=yes +ExecStart=/usr/bin/zramstart +ExecStop=/usr/bin/zramstop +Type=oneshot + +[Install] +WantedBy=multi-user.target diff --git a/source/apps-extra/zramswap-enabler/zramstart b/source/apps-extra/zramswap-enabler/zramstart new file mode 100755 index 0000000..f6a10b9 --- /dev/null +++ b/source/apps-extra/zramswap-enabler/zramstart @@ -0,0 +1,31 @@ +#!/bin/bash + +# get the number of CPUs +num_cpus=$(grep -c processor /proc/cpuinfo) +# if something goes wrong, assume we have 1 +[ "$num_cpus" != 0 ] || num_cpus=1 + +# 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 | grep -E --only-matching '[[:digit:]]+') +mem_total=$((mem_total_kb * 1024)) + +# load dependency modules +modprobe zram num_devices=$num_cpus + +# initialize the devices +for i in $(seq 0 $decr_num_cpus); do +echo $((mem_total / num_cpus)) > /sys/block/zram$i/disksize +done + +# Creating swap filesystems +for i in $(seq 0 $decr_num_cpus); do +mkswap /dev/zram$i +done + +# Switch the swaps on +for i in $(seq 0 $decr_num_cpus); do +swapon -p 100 /dev/zram$i +done diff --git a/source/apps-extra/zramswap-enabler/zramstop b/source/apps-extra/zramswap-enabler/zramstop new file mode 100755 index 0000000..2356967 --- /dev/null +++ b/source/apps-extra/zramswap-enabler/zramstop @@ -0,0 +1,18 @@ +#!/bin/bash + +# get the number of CPUs +num_cpus=$(grep -c processor /proc/cpuinfo) + +# set decremented number of CPUs +decr_num_cpus=$((num_cpus - 1)) + +# Switching off swap +for i in $(seq 0 $decr_num_cpus); do +if [ "$(grep /dev/zram$i /proc/swaps)" != "" ]; then +swapoff /dev/zram$i +sleep 1 +fi +done + +sleep 1 +rmmod zram _______________________________________________ Frugalware-git mailing list Frugalware-git@frugalware.org http://frugalware.org/mailman/listinfo/frugalware-git