summaryrefslogtreecommitdiffstats
path: root/data
diff options
context:
space:
mode:
Diffstat (limited to 'data')
-rw-r--r--data/activate-swap.sh (renamed from data/activate-swap)25
-rw-r--r--data/analyse-disk.sh48
-rw-r--r--data/disk-tmp.sh23
3 files changed, 55 insertions, 41 deletions
diff --git a/data/activate-swap b/data/activate-swap.sh
index 10cb42e9..edaad1f2 100644
--- a/data/activate-swap
+++ b/data/activate-swap.sh
@@ -9,22 +9,27 @@
#
# 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
+# 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 mount-disk.sh
-# depends on availability of the appropriate kernel module/functionality
+# Depends on analyse-disk.sh and 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
+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 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 0c152dbf..a7145427 100644
--- a/data/analyse-disk.sh
+++ b/data/analyse-disk.sh
@@ -9,30 +9,26 @@
#
# General information about OpenSLX can be found under http://openslx.org
#
-# Local hard disk autoconfiguration script for OpenSLX linux stateless
-# clients, detecting swap and special partitions
+# Local hard disk autodetection script for OpenSLX linux stateless clients,
+# detecting swap and special partitions
#############################################################################
-# Todo:
-# * This script should be run just once per boot!
-# * The activation of swap could/should be handled in separate script!?
-# * The mounting of /tmp could/should be done separately?
-# * Same for other partitions, use information of /etc/fstab for that?
-# * Should we just install xfs in the source system and boil down everything
-# onto that?
-
# General formatter for the /tmp partition on a local harddisk
diskfm () {
local target=$1
-local mntpnt=$2
local fs
local path
-for fs in xfs reiserfs ext2 ; do
- if strinfile "$fs" /proc/filesystems || modprobe ${MODPRV} $fs ; then
- unset $found
+for fs in xfs ext3 ext2 ; do
+ unset available
+ case $(cat /proc/filesystems) in
+ *${fs}*) available=yes;;
+ *) modprobe -q ${fs} 2>/dev/null && available=yes;;
+ esac
+ if [ -n ${available} ]; then
+ unset found
for path in /sbin /bin /usr/sbin /usr/bin ; do
- if test -x /mnt/$path/mkfs.$fs ; then
+ if test -x /$path/mkfs.$fs ; then
found=yes
case mkfs.$fs in
mkfs.xfs)
@@ -48,19 +44,9 @@ for fs in xfs reiserfs ext2 ; do
mopt="-o noexec"
;;
esac
- mkfs.$fs $fopt $target >/dev/null 2>&1 #|| error
- if [ -z $mntpnt ] ; then
- umount /tmp 2>/dev/null
- if mount -t $fs -n $mopt $target /tmp 2>/dev/null; then
- return 0
- else
- mount -n -t tmpfs none /tmp
- fi
- else
- mkdir -p $mntpnt
- mount -t $fs -n -o loop $target $mntpnt 2>/dev/null
- return 0
- fi
+ mkfs.$fs ${fopt} ${target} >/dev/null 2>&1 #|| error
+ mkdir -p /run/mount/tmp
+ mount -t ${fs} ${target} /run/mount/tmp
fi
done
[ -z $found ] && continue
@@ -70,7 +56,7 @@ done
}
# Check for local harddisks and appropriate partitions
-fdisk -l /dev/$hd|sed -n "/^\/dev\//p" >/etc/disk.partition
+fdisk -l |sed -n "/^\/dev\//p" >/etc/disk.partition
# Check for standard swap partitions and make them available to the system
for hdpartnr in $(cat /etc/disk.partition | \
@@ -85,8 +71,8 @@ for hdpartnr in $(cat /etc/disk.partition | \
sed -n -e "/ 44 /p"|sed -e "s/[[:space:]].*//") ; do
# 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 "$hdpartnr is mounted to /mnt/tmp at $(sysup)" >/tmp/tmpready
+ 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 ) &
diff --git a/data/disk-tmp.sh b/data/disk-tmp.sh
new file mode 100644
index 00000000..842d8230
--- /dev/null
+++ b/data/disk-tmp.sh
@@ -0,0 +1,23 @@
+#!/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
+#
+# Mount local ID44 partition to /tmp after all existing stuff is preserved
+
+#############################################################################
+
+# Check if ID44 is available by analysing /etc/fstab for appropriate entry
+if grep -qe "/dev/.*/tmp" /etc/fstab 2>/dev/null ; then
+ mkdir -p /run/tmp
+ mv /tmp/* /run/tmp
+ mount --move /run/mount/tmp /tmp
+ mv /run/tmp/* /tmp
+ rmdir /run/tmp
+fi