diff options
author | marav <marav8@free.fr> | 2022-04-23 00:57:29 +0700 |
---|---|---|
committer | Willy Sudiarto Raharjo <willysr@slackbuilds.org> | 2022-04-24 01:47:22 +0700 |
commit | 12351235e59bd24a4df8f82092d9e0234cfb2de7 (patch) | |
tree | 466496f0f3a4ad6dfbef27ab8480389035dfc2c1 /system/swapinzram | |
parent | 5d6f5801863fc51cfc1a4847abad02893ab381b8 (diff) | |
download | slackbuilds-12351235e59bd24a4df8f82092d9e0234cfb2de7.tar.gz |
system/swapinzram: Added (Configure a swap block device in RAM).
Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
Diffstat (limited to 'system/swapinzram')
-rw-r--r-- | system/swapinzram/README | 30 | ||||
-rw-r--r-- | system/swapinzram/doinst.sh | 15 | ||||
-rw-r--r-- | system/swapinzram/slack-desc | 19 | ||||
-rw-r--r-- | system/swapinzram/swapinzram.SlackBuild | 68 | ||||
-rw-r--r-- | system/swapinzram/swapinzram.info | 10 |
5 files changed, 142 insertions, 0 deletions
diff --git a/system/swapinzram/README b/system/swapinzram/README new file mode 100644 index 0000000000..99a48effc0 --- /dev/null +++ b/system/swapinzram/README @@ -0,0 +1,30 @@ +# swapinzram for Slackware +Modified swapinzram script by Didier Spaier +http://slackware.uk/slint/x86_64/slint-15.0/source/swapinzram/ + + +The package swapinzram is intended to extend the swap spaces available +beyond swap partitions and swap files, providing swap space in the form +of a block device in compressed RAM, using the zram kernel module. +As the files in it are compressed this results in an increase of the +RAM size usable by the system at the cost of a small overhead to +compress and decompress the files. + +This can be useful to: +1. Avoid or at least delay swapping on a mass storage device when +available space in RAM decreases. This results in a performance gain +because writing in RAM is way faster that on a hard disk or even an SSD +2. Less writing on a storage devices like flash drives, eMMC, USB flash +drives or SD card, if the swap partition or file is installed on such +devices. +Beyond the performance gain this also minimizes wearing of the device. + +zram can also be used to create block devices in RAM for other usages, +like to store the files in /tmp or the kernel log, but this is not in +the scope of this package. However as we pick an available zram device +id there should be no conflict when adding these features. + +Also in the TODO list, allow to write idle/incompressible pages to a +backing storage rather than keeping them in memory. The documentation +states that the backing storage should be a swap partition, not a swap +file, but I will check if it's still true. diff --git a/system/swapinzram/doinst.sh b/system/swapinzram/doinst.sh new file mode 100644 index 0000000000..6856f514ad --- /dev/null +++ b/system/swapinzram/doinst.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +config() { + NEW="$1" + OLD="$(dirname $NEW)/$(basename $NEW .new)" + + if [ ! -r $OLD ]; then + mv $NEW $OLD + elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then + rm $NEW + fi +} + +config etc/swapinzram.conf.new +config etc/sysctl.d/10-zram.conf.new diff --git a/system/swapinzram/slack-desc b/system/swapinzram/slack-desc new file mode 100644 index 0000000000..40404e3891 --- /dev/null +++ b/system/swapinzram/slack-desc @@ -0,0 +1,19 @@ +# HOW TO EDIT THIS FILE: +# The "handy ruler" below makes it easier to edit a package description. +# Line up the first '|' above the ':' following the base package name, and +# the '|' on the right side marks the last column you can put a character in. +# You must make exactly 11 lines for the formatting to be correct. It's also +# customary to leave one space after the ':' except on otherwise blank lines. + + |-----handy-ruler------------------------------------------------------| +swapinzram: swapinzram (Configure a swap block device in RAM) +swapinzram: +swapinzram: Zram creates a compressed block device in memory, and the RAM +swapinzram: assigned to it is only used for swapping as-needed (until then, the +swapinzram: RAM is still available for use by applications). +swapinzram: Swap data stored is compressed thereby allowing more data to be +swapinzram: stored in RAM. +swapinzram: +swapinzram: +swapinzram: https://www.kernel.org/doc/html/latest/admin-guide/blockdev/zram.html +swapinzram: diff --git a/system/swapinzram/swapinzram.SlackBuild b/system/swapinzram/swapinzram.SlackBuild new file mode 100644 index 0000000000..950061a682 --- /dev/null +++ b/system/swapinzram/swapinzram.SlackBuild @@ -0,0 +1,68 @@ +#!/bin/bash +# +# Copyright 2022 marav, Paris, FR +# All rights reserved. +# +# Redistribution and use of this script, with or without modification, is +# permitted provided that the following conditions are met: +# +# 1. Redistributions of this script must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +PRGNAM=swapinzram +SRC_SCRIPTS="swapinzram-files.tar.gz" +VERSION=${VERSION:-1.0} +ARCH=noarch +BUILD=${BUILD:-1} +TAG=${TAG:-_SBo} +PKGTYPE=${PKGTYPE:-tgz} + +if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then + echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE" + exit 0 +fi + +CWD=$(pwd) +TMP=${TMP:-/tmp/SBo} +PKG=$TMP/package-$PRGNAM +OUTPUT=${OUTPUT:-/tmp} + +rm -rf $PKG +mkdir -p $TMP $PKG +mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION +mkdir -p $PKG/{install,etc/rc.d,etc/sysctl.d} + +tar -xvf $SRC_SCRIPTS -C $PKG || exit 1 + +mv $PKG/rc.swapinzram $PKG/etc/rc.d + chmod 644 $PKG/etc/rc.d/rc.swapinzram + chown root:root -R $PKG/etc/rc.d/rc.swapinzram + +mv $PKG/swapinzram.conf $PKG/etc/swapinzram.conf.new + chmod 644 $PKG/etc/swapinzram.conf.new + +mv $PKG/10-zram.conf $PKG/etc/sysctl.d/10-zram.conf.new + chmod 644 $PKG/etc/sysctl.d/10-zram.conf.new + +cp $CWD/README $PKG/usr/doc/$PRGNAM-$VERSION/ +cp $CWD/$PRGNAM.SlackBuild $PKG/usr/doc/$PRGNAM-$VERSION/ + chmod 644 $PKG/usr/doc/$PRGNAM-$VERSION/* + + +mkdir -p $PKG/install +cat $CWD/doinst.sh > $PKG/install/doinst.sh +cat $CWD/slack-desc > $PKG/install/slack-desc + +cd $PKG +/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE diff --git a/system/swapinzram/swapinzram.info b/system/swapinzram/swapinzram.info new file mode 100644 index 0000000000..b435ec5c90 --- /dev/null +++ b/system/swapinzram/swapinzram.info @@ -0,0 +1,10 @@ +PRGNAM="swapinzram" +VERSION="1.0" +HOMEPAGE="https://gitlab.com/maravtdm/swapinzram-slackbuild" +DOWNLOAD="https://master.dl.sourceforge.net/project/swapinzram-src/swapinzram-files.tar.gz" +MD5SUM="48d5cdaa3d20013689747d0836dcc98c" +DOWNLOAD_x86_64="" +MD5SUM_x86_64="" +REQUIRES="" +MAINTAINER="marav" +EMAIL="marav8@free.fr" |