blob: edaad1f23cc3c5c5214904bf9bf2445b5de9602c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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
|