From 6c096421db0a398960b44ec6d3dc1c3a2c081c46 Mon Sep 17 00:00:00 2001 From: Dirk Date: Tue, 19 Mar 2013 18:02:11 +0100 Subject: Should be added to systemd ... --- data/analyse-disk.sh | 46 ++++++++++++++++------------------------------ 1 file changed, 16 insertions(+), 30 deletions(-) (limited to 'data') diff --git a/data/analyse-disk.sh b/data/analyse-disk.sh index 0c152dbf..ac63956e 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 /var/mnt/tmp + mount -t ${fs} ${target} /var/mnt/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,7 +71,7 @@ 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 "$hdpartnr is mounted to /mnt/tmp at $(sysup)" >/tmp/tmpready echo -e "$hdpartnr\t/tmp\t\tauto\t\tdefaults\t 0 0" >>/etc/fstab else echo "formatting failed for some reason ($(sysup))" >/tmp/tmpready -- cgit v1.2.3-55-g7522 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 From e7eae989f474cecf7638674cbfd9b042356fdf3b Mon Sep 17 00:00:00 2001 From: Dirk Date: Tue, 19 Mar 2013 18:51:22 +0100 Subject: Enable /tmp on ID44 partition if available. --- data/analyse-disk.sh | 4 ++-- data/disk-tmp.sh | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 data/disk-tmp.sh (limited to 'data') diff --git a/data/analyse-disk.sh b/data/analyse-disk.sh index 908ee298..a7145427 100644 --- a/data/analyse-disk.sh +++ b/data/analyse-disk.sh @@ -45,8 +45,8 @@ for fs in xfs ext3 ext2 ; do ;; esac mkfs.$fs ${fopt} ${target} >/dev/null 2>&1 #|| error - mkdir -p /var/mnt/tmp - mount -t ${fs} ${target} /var/mnt/tmp + mkdir -p /run/mount/tmp + mount -t ${fs} ${target} /run/mount/tmp fi done [ -z $found ] && continue 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 -- cgit v1.2.3-55-g7522