From 3ab7f117555d80951b026163b757c8992592f151 Mon Sep 17 00:00:00 2001 From: Dirk Date: Tue, 19 Mar 2013 18:37:15 +0100 Subject: Stuff to activate swap ... --- data/activate-swap | 30 ------------------------------ data/activate-swap.sh | 35 +++++++++++++++++++++++++++++++++++ data/analyse-disk.sh | 2 +- 3 files changed, 36 insertions(+), 31 deletions(-) delete mode 100644 data/activate-swap create mode 100644 data/activate-swap.sh (limited to 'data') diff --git a/data/activate-swap b/data/activate-swap deleted file mode 100644 index 10cb42e9..00000000 --- a/data/activate-swap +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/sh -# Copyright (c) 2013 - OpenSLX GmbH -# -# This program is free software distributed under the GPL version 2. -# See http://openslx.org/COPYING -# -# If you have any feedback please consult http://openslx.org/feedback and -# send your feedback to feedback@openslx.org -# -# General information about OpenSLX can be found under http://openslx.org -# -# Initialize swap for OpenSLX linux stateless clients, both for swap on local -# disk partitions as well as compressed ramzswap or similar - -############################################################################# - -# depends on mount-disk.sh -# depends on availability of the appropriate kernel module/functionality - -# try to enable compressed RAM SWAP / ZRAM -if modprobe ${MODPRV} ramzswap 2>/dev/null && [ -f /usr/bin/rzscontrol ] ; then - rzscontrol /dev/ramzswap0 --init - swapon /dev/ramzswap0 2>/dev/null - #hdswap="# disk swap disabled because of enabled compressed ramswap" -elif modprobe ${MODPRV} zram 2>/dev/null ; then - # assign a quarter of total mem to zram - echo $(( $(free -k | awk '/^Mem:/ { print $2 }') * 256 )) > /sys/block/zram0/disksize - mkswap /dev/zram0 2>/dev/null - swapon /dev/zram0 2>/dev/null -fi diff --git a/data/activate-swap.sh b/data/activate-swap.sh new file mode 100644 index 00000000..edaad1f2 --- /dev/null +++ b/data/activate-swap.sh @@ -0,0 +1,35 @@ +#!/bin/sh +# Copyright (c) 2013 - OpenSLX GmbH +# +# This program is free software distributed under the GPL version 2. +# See http://openslx.org/COPYING +# +# If you have any feedback please consult http://openslx.org/feedback and +# send your feedback to feedback@openslx.org +# +# General information about OpenSLX can be found under http://openslx.org +# +# Initialize swap for OpenSLX linux stateless clients, first for swap as +# compressed RAM (zram) and then on local disk partitions, if detected by +# disk-analyse.sh script + +############################################################################# + +# Depends on analyse-disk.sh and on availability of the appropriate kernel +# module/functionality + +# try to enable compressed RAM SWAP / ZRAM +if modprobe -q zram 2>/dev/null ; then + # assign a quarter of total mem to zram + echo $(( $(free -k | awk '/^Mem:/ { print $2 }') * 256 )) > /sys/block/zram0/disksize + mkswap /dev/zram0 2>/dev/null + swapon /dev/zram0 1>/dev/null 2>/dev/null +fi + +# add on-disk swap if available +for hdpartnr in $(cat /etc/fstab | sed -n -e "/swap.*swap/p"| \ + sed -e "s/[[:space:]].*//") ; do + mkswap ${hdpartnr} 2>/dev/null + swapon ${hdpartnr} 1>/dev/null 2>/dev/null +done + diff --git a/data/analyse-disk.sh b/data/analyse-disk.sh index ac63956e..908ee298 100644 --- a/data/analyse-disk.sh +++ b/data/analyse-disk.sh @@ -72,7 +72,7 @@ for hdpartnr in $(cat /etc/disk.partition | \ # check for supported filesystem and formatter ( if diskfm $hdpartnr ; then # echo "$hdpartnr is mounted to /mnt/tmp at $(sysup)" >/tmp/tmpready - echo -e "$hdpartnr\t/tmp\t\tauto\t\tdefaults\t 0 0" >>/etc/fstab + echo -e "$hdpartnr\t/tmp\t\tnoauto\t\tdefaults\t 0 0" >>/etc/fstab else echo "formatting failed for some reason ($(sysup))" >/tmp/tmpready fi ) & -- cgit v1.2.3-55-g7522