summaryrefslogtreecommitdiffstats
path: root/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_partitions
diff options
context:
space:
mode:
Diffstat (limited to 'remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_partitions')
-rwxr-xr-xremote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_partitions83
1 files changed, 37 insertions, 46 deletions
diff --git a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_partitions b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_partitions
index 17202418..748e017d 100755
--- a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_partitions
+++ b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_partitions
@@ -1,4 +1,4 @@
-#!/bin/ash
+#!/bin/bash
# Copyright (c) 2013 - OpenSLX GmbH
#
# This program is free software distributed under the GPL version 2.
@@ -13,12 +13,8 @@
# detecting swap and special partitions
#############################################################################
-
-# Mount point for persistent scratch partition (type 49 for BOOT, type48 for CACHE, type 47 for HOME)
-
-PERSISTENT_BOOT="/boot"
-PERSISTENT_CACHE="/cache"
-PERSISTENT_HOME="/home"
+CONFIGPATH="./config"
+. $CONFIGPATH
# General formatter for the /tmp partition on a local harddisk
diskfm () {
@@ -94,43 +90,49 @@ mount_temp_fallback () {
mount_part() { # $1=mountpoint, $2=partition(/dev/*)
mkdir -p "$1"
- if ! mount -t auto -o noexec "${2}" "$1"; then
+ if ! mount -t auto -o noexec "${2}" "$1" 2> /dev/null ; then
diskfm "$2" "jfs xfs ext3" || continue
mount -t auto -o noexec "${2}" "$1" || continue
fi
echo -e "${2}\t${1}\tauto\t\tnoauto,noexec\t\t 0 0" >> "/etc/fstab"
}
+# default case
+if [ -z "$SLX_PARTITION_TABLE" ]; then
+ SLX_PARTITION_TABLE='
+ 44,10G,/tmp
+ 45,10G,/var/scratch'
+fi
+
declare -A PARTTBL
COUNTER=1
-if [ -n "$SLX_PARTITION_TABLE" ]; then
- for PARTITION in $SLX_PARTITION_TABLE; do
- IFS=,
- set $PARTITION
- PARTTBL["$COUNTER/id"]=$1
- PARTTBL["$COUNTER/size"]=$(echo $2 | egrep -o "[0-9]*")
- PARTTBL["$COUNTER/mountpoint"]=$3
- if [ -e $4 ]; then
- PARTTBL["$COUNTER/bootable"]=0
- else
- PARTTBL["$COUNTER/bootable"]=1
- fi
- # set the partitions to non-existents
- PARTTBL["$COUNTER/persistent"]="no"
- COUNTER=$(($COUNTER+1))
- done
- unset IFS
-fi
+for PARTITION in $SLX_PARTITION_TABLE; do
+ IFS=,
+ set $PARTITION
+ PARTTBL["$COUNTER/id"]=$1
+ PARTTBL["$COUNTER/size"]=$(echo $2 | egrep -o "[0-9]*")
+ PARTTBL["$COUNTER/mountpoint"]=$3
+ if [ -e $4 ]; then
+ PARTTBL["$COUNTER/bootable"]=0
+ else
+ PARTTBL["$COUNTER/bootable"]=1
+ fi
+ PARTTBL["$COUNTER/persistent"]="no"
+ COUNTER=$(($COUNTER+1))
+done
+unset IFS
+
# create the /etc/disk.partition file with all the partitions and respective id's (MSDOS and GPT)
+echo "PARTITION - ID" > "/etc/disk.partition"
for hd in $(cat /proc/partitions | tr -s ' ' | cut -d ' ' -f5 | grep -o -e "[a-z]*$"); do
- echo -n "$hd - " >> "/etc/disk.partition"
+ echo -n "$hd (" >> "/etc/disk.partition"
sfdisk -d /dev/$hd 2>&1 | grep 'GPT' > /dev/null
if [[ $? -eq 1 ]]; then
- echo "MSDOS" >> "/etc/disk.partition"
- fdisk /dev/$hd -l | sed -n "/^\/dev\//p" | tr -s ' ' | cut -d ' ' -f1,5 >> "/etc/disk.partition"
+ echo "MSDOS)" >> "/etc/disk.partition"
+ fdisk /dev/$hd -l | sed -n "/^\/dev\//p" | tr -d '*' | tr -s ' ' | cut -d ' ' -f1,5 >> "/etc/disk.partition"
else
- echo "GPT" >> "/etc/disk.partition"
+ echo "GPT)" >> "/etc/disk.partition"
for part in $(cat /proc/partitions | tr -s ' ' | cut -d ' ' -f5 | grep -o -e "$hd[0-9][0-9]*$"); do
LINE="/dev/$part "
LINE=$LINE$(sgdisk /dev/$hd -i ${part:3} | grep 'GUID code' | cut -d ' ' -f4)
@@ -141,7 +143,6 @@ done
echo "Partitions:"
cat "/etc/disk.partition"
-
# Check for standard swap partitions and make them available to the system
HAVE_SWAP=no
for swppart in $(grep -e "82$\|0657FD6D-A4AB-43C4-84E5-0933C84B4F4F$" /etc/disk.partition | cut -d ' ' -f1); do
@@ -162,37 +163,28 @@ for openslxpart in $(grep -e "46$\|46000000-0000-0000-0000-000000000000$" /etc/d
echo -e "${openslxpart}\t/media/${openslxpart#/dev/*}\tauto\t\tnoauto\t\t 0 0" >> "/etc/fstab"
done
-# We use special non assigned partition type (id44) for harddisk scratch
-# space, thus no normal filesystem will be incidentally deleted or
-# corrupted
-
-# Put detected linux partitions (83) into /etc/fstab with "noauto", special
-# partition 45 (persistent scratch) to /var/scratch and 46 to /var/openslx
-
-# for partid in 83 0FC63DAF-8483-4772-8E79-3D69D8477DE4 49 48 47 46; do
-
HAVE_TEMP="no"
for (( i = 1; i < $COUNTER; i++ )); do
- for hdpartnr in $(grep -e ${PARTTBL["$i/id"]} /etc/disk.partition | cut -d ' ' -f1); do
+ for hdpartnr in $(grep -e ${PARTTBL["$i/id"]}"$\|"${PARTTBL["$i/id"]}"000000-0000-0000-0000-000000000000$" /etc/disk.partition | cut -d ' ' -f1); do
if [ "${PARTTBL["$i/mountpoint"]}" = "/tmp" ]; then
if diskfm "$hdpartnr"; then
# echo "$hdpartnr is mounted to /mnt/tmp at $(sysup)" >/tmp/tmpready
mount_temp "$mopt" "$hdpartnr" || continue
echo -e "${hdpartnr}\t/tmp\t\tauto\t\tnoexec\t 0 0" >> "/etc/fstab"
HAVE_TEMP="yes"
- break
+ PARTTBL["$i/persistent"]="yes"
else
echo "formatting failed for some reason"
fi # Made this non-forking, systemd should handle it - 2013-05-28
+ else
+ mount_part "${PARTTBL["$i/mountpoint"]}" $hdpartnr
+ PARTTBL["$i/persistent"]="yes"
fi
- mount_part "${PARTTBL["$i/mountpoint"]}" $hdpartnr
- PARTTBL["$i/persistent"]="yes"
done
[ "${PARTTBL["$i/persistent"]}" = "no" -a -d "${PARTTBL["$i/mountpoint"]}" ] && rm -f "${PARTTBL["$i/mountpoint"]}"
done
mount -a
-
# Make huge tmpfs if nothing could be mounted for /tmp
if [ "$HAVE_TEMP" = "no" ]; then
mount_temp -t tmpfs -o size=20G none
@@ -201,5 +193,4 @@ fi
if [ "$HAVE_SWAP" = "no" ]; then
slxlog "partition-swap" "Have no (formatted) swap partition, using zram swap only!" "/etc/disk.partition"
fi
-
exit 0 \ No newline at end of file