summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLucas Affonso Xavier de Morais2014-08-21 19:16:45 +0200
committerMichael Pereira Neves2014-10-28 14:14:49 +0100
commita177e6c101586bb89a8d6c642b891aa071f65674 (patch)
tree8ae46a0c792ae8d2be06bf7aa50234b67a7d95e3
parent[partitioner] setup_partitions adapted to work with GPT (need some tests) (diff)
downloadtm-scripts-a177e6c101586bb89a8d6c642b891aa071f65674.tar.gz
tm-scripts-a177e6c101586bb89a8d6c642b891aa071f65674.tar.xz
tm-scripts-a177e6c101586bb89a8d6c642b891aa071f65674.zip
[partitioner] setup_partitions using GPT types and SLX_PARTITION_TABLE, lacking default configuration and some tests.
-rwxr-xr-xremote/modules/partitioner/partitioner.sh2
-rwxr-xr-xremote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_partitions131
2 files changed, 69 insertions, 64 deletions
diff --git a/remote/modules/partitioner/partitioner.sh b/remote/modules/partitioner/partitioner.sh
index bc7fac84..118d420a 100755
--- a/remote/modules/partitioner/partitioner.sh
+++ b/remote/modules/partitioner/partitioner.sh
@@ -238,7 +238,7 @@ if [ $SLX_PARTITION_TYPE = 'GPT' ]; then
for (( i = 1; i < $COUNTER; i++ )); do
if [ $i -ne 4 ]; then
if [ ${PARTTBL["$SLX_CHOOSEN_DISK$i/exists"]} = 0 ]; then
- CMD=$CMD" -u "$i":"${PARTTBL["$SLX_CHOOSEN_DISK$i/id"]}"000000-0000-0000-0000-000000000000"
+ CMD=$CMD" -t "$i":"${PARTTBL["$SLX_CHOOSEN_DISK$i/id"]}"000000-0000-0000-0000-000000000000"
fi
CMD=$CMD" -c "$i":\""${PARTTBL["$SLX_CHOOSEN_DISK$i/mountpoint"]}"\""
fi
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 f71410f3..17202418 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
@@ -15,6 +15,7 @@
#############################################################################
# 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"
@@ -90,6 +91,38 @@ mount_temp_fallback () {
rmdir /tmptmp
return 0
}
+
+mount_part() { # $1=mountpoint, $2=partition(/dev/*)
+ mkdir -p "$1"
+ if ! mount -t auto -o noexec "${2}" "$1"; 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"
+}
+
+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
+
+# create the /etc/disk.partition file with all the partitions and respective id's (MSDOS and GPT)
for hd in $(cat /proc/partitions | tr -s ' ' | cut -d ' ' -f5 | grep -o -e "[a-z]*$"); do
echo -n "$hd - " >> "/etc/disk.partition"
sfdisk -d /dev/$hd 2>&1 | grep 'GPT' > /dev/null
@@ -111,80 +144,52 @@ cat "/etc/disk.partition"
# Check for standard swap partitions and make them available to the system
HAVE_SWAP=no
-# gpt swap GUID = 0657FD6D-A4AB-43C4-84E5-0933C84B4F4F
-for hdpartnr in $(grep -e "82$\|0657FD6D-A4AB-43C4-84E5-0933C84B4F4F$" /etc/disk.partition | cut -d ' ' -f1); do
- echo -e "$hdpartnr\tswap\t\tswap\t\tdefaults\t 0 0" >> "/etc/fstab"
- swapon "$hdpartnr" -p 10 && HAVE_SWAP=yes # low priority, in case we have zram swap, prefer that)
+for swppart in $(grep -e "82$\|0657FD6D-A4AB-43C4-84E5-0933C84B4F4F$" /etc/disk.partition | cut -d ' ' -f1); do
+ echo -e "$swppart\tswap\t\tswap\t\tdefaults\t 0 0" >> "/etc/fstab"
+ swapon "$swppart" -p 10 && HAVE_SWAP=yes # low priority, in case we have zram swap, prefer that)
+done
+# Put detected linux partitions (83) into /etc/fstab with "noauto"
+for linuxpart in $(grep -e "83$\|0FC63DAF-8483-4772-8E79-3D69D8477DE4$" /etc/disk.partition | cut -d ' ' -f1); do
+ mkdir -p "/media/${linuxpart#/dev/*}"
+ echo -e "${linuxpart}\t/media/${linuxpart#/dev/*}\tauto\t\tnoauto,noexec\t 0 0" >> "/etc/fstab"
+done
+
+for openslxpart in $(grep -e "46$\|46000000-0000-0000-0000-000000000000$" /etc/disk.partition | cut -d ' ' -f1); do
+ mkdir -p "/media/${openslxpart#/dev/*}"
+ #mount -t auto ${openslxpart} /mnt/media/${openslxpart#/dev/*} \n\
+ #test -d /mnt/media/${openslxpart#/dev/*}/home && \
+ # ln -sf /media/${openslxpart#/dev/*} /var/home
+ 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
-HAVE_TEMP=no
-for hdpartnr in $(grep -e "44$\|44000000-0000-0000-0000-000000000000$" /etc/disk.partition | cut -d ' ' -f1); do
- # check for supported filesystem and formatter
- 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
- else
- echo "formatting failed for some reason"
- fi # Made this non-forking, systemd should handle it - 2013-05-28
-done
# Put detected linux partitions (83) into /etc/fstab with "noauto", special
# partition 45 (persistent scratch) to /var/scratch and 46 to /var/openslx
-HAVE_PERSISTENT_BOOT=no
-HAVE_PERSISTENT_CACHE=no
-HAVE_PERSISTENT_HOME=no
-for partid in 83 0FC63DAF-8483-4772-8E79-3D69D8477DE4 49 48 47 46; do
- for hdpartnr in $(grep -e $partid /etc/disk.partition | cut -d ' ' -f1); do
- if [ "${partid}" -eq 83 -o "$partid" = "0FC63DAF-8483-4772-8E79-3D69D8477DE4" ]; then
- mkdir -p "/media/${hdpartnr#/dev/*}"
- echo -e "${hdpartnr}\t/media/${hdpartnr#/dev/*}\tauto\t\tnoauto,noexec\t 0 0" >> "/etc/fstab"
-
- elif [ "${partid}" -eq 49 -o "$partid" = "49000000-0000-0000-0000-000000000000" -a "$HAVE_PERSISTENT_BOOT" = "no" ]; then
- mkdir -p "$PERSISTENT_BOOT"
- if ! mount -t auto -o noexec "${hdpartnr}" "$PERSISTENT_BOOT"; then
- diskfm "$hdpartnr" "jfs xfs ext3" || continue
- mount -t auto -o noexec "${hdpartnr}" "$PERSISTENT_BOOT" || continue
- fi
- HAVE_PERSISTENT_BOOT=yes
- echo -e "${hdpartnr}\t${PERSISTENT_BOOT}\tauto\t\tnoauto,noexec\t\t 0 0" >> "/etc/fstab"
-
- elif [ "${partid}" -eq 48 -o "$partid" = "48000000-0000-0000-0000-000000000000" -a "$HAVE_PERSISTENT_CACHE" = "no" ]; then
- mkdir -p "$PERSISTENT_CACHE"
- if ! mount -t auto -o noexec "${hdpartnr}" "$PERSISTENT_CACHE"; then
- diskfm "$hdpartnr" "jfs xfs ext3" || continue
- mount -t auto -o noexec "${hdpartnr}" "$PERSISTENT_CACHE" || continue
- fi
- HAVE_PERSISTENT_CACHE=yes
- echo -e "${hdpartnr}\t${PERSISTENT_CACHE}\tauto\t\tnoauto,noexec\t\t 0 0" >> "/etc/fstab"
-
- elif [ "${partid}" -eq 47 -o "$partid" = "47000000-0000-0000-0000-000000000000" -a "$HAVE_PERSISTENT_HOME" = "no" ]; then
- mkdir -p "$PERSISTENT_HOME"
- if ! mount -t auto -o noexec "${hdpartnr}" "$PERSISTENT_HOME"; then
- diskfm "$hdpartnr" "jfs xfs ext3" || continue
- mount -t auto -o noexec "${hdpartnr}" "$PERSISTENT_HOME" || continue
- fi
- HAVE_PERSISTENT_HOME=yes
- echo -e "${hdpartnr}\t${PERSISTENT_HOME}\tauto\t\tnoauto,noexec\t\t 0 0" >> "/etc/fstab"
-
-
- elif [ "${partid}" -eq 46 -o "$partid" = "46000000-0000-0000-0000-000000000000" ]; then
- mkdir -p "/media/${hdpartnr#/dev/*}"
- #mount -t auto ${hdpartnr} /mnt/media/${hdpartnr#/dev/*} \n\
- #test -d /mnt/media/${hdpartnr#/dev/*}/home && \
- # ln -sf /media/${hdpartnr#/dev/*} /var/home
- echo -e "${hdpartnr}\t/media/${hdpartnr#/dev/*}\tauto\t\tnoauto\t\t 0 0" >> "/etc/fstab"
+
+# 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
+ 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
+ else
+ echo "formatting failed for some reason"
+ fi # Made this non-forking, systemd should handle it - 2013-05-28
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
-[ "$HAVE_PERSISTENT_BOOT" = "no" -a -d "$PERSISTENT_BOOT" ] && rm -f "$PERSISTENT_BOOT"
-[ "$HAVE_PERSISTENT_CACHE" = "no" -a -d "$PERSISTENT_CACHE" ] && rm -f "$PERSISTENT_CACHE"
-[ "$HAVE_PERSISTENT_HOME" = "no" -a -d "$PERSISTENT_HOME" ] && rm -f "$PERSISTENT_HOME"
mount -a