summaryrefslogtreecommitdiffstats
path: root/data
diff options
context:
space:
mode:
authorJonathan Bauer2013-02-20 16:06:59 +0100
committerJonathan Bauer2013-02-20 16:06:59 +0100
commit83c04611fba86c281c2b469ff7118e2102b423e3 (patch)
tree5946862f5c2339434ab7d1d6cc110c01ce25d09e /data
parentinit auto ip config (diff)
downloadtm-scripts-83c04611fba86c281c2b469ff7118e2102b423e3.tar.gz
tm-scripts-83c04611fba86c281c2b469ff7118e2102b423e3.tar.xz
tm-scripts-83c04611fba86c281c2b469ff7118e2102b423e3.zip
?
Diffstat (limited to 'data')
-rw-r--r--data/activate-swap30
1 files changed, 30 insertions, 0 deletions
diff --git a/data/activate-swap b/data/activate-swap
new file mode 100644
index 00000000..10cb42e9
--- /dev/null
+++ b/data/activate-swap
@@ -0,0 +1,30 @@
+#!/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