summaryrefslogtreecommitdiffstats
path: root/testModule/hooks/pre-pivot/mount-tmp.sh
diff options
context:
space:
mode:
authorJonathan Bauer2015-05-06 18:13:52 +0200
committerJonathan Bauer2015-05-06 18:13:52 +0200
commitb3312f86061a0d887233f5068cbc335aa2612bed (patch)
tree32a0bace5eb6a7afeb29dae80d7f01fefecb36cc /testModule/hooks/pre-pivot/mount-tmp.sh
parentMerge branch 'master' of git.openslx.org:openslx-ng/systemd-init (diff)
downloadsystemd-init-b3312f86061a0d887233f5068cbc335aa2612bed.tar.gz
systemd-init-b3312f86061a0d887233f5068cbc335aa2612bed.tar.xz
systemd-init-b3312f86061a0d887233f5068cbc335aa2612bed.zip
current state: udev disk detection still not done!
also improved module structure and code commentary
Diffstat (limited to 'testModule/hooks/pre-pivot/mount-tmp.sh')
-rwxr-xr-xtestModule/hooks/pre-pivot/mount-tmp.sh38
1 files changed, 38 insertions, 0 deletions
diff --git a/testModule/hooks/pre-pivot/mount-tmp.sh b/testModule/hooks/pre-pivot/mount-tmp.sh
new file mode 100755
index 00000000..152c844e
--- /dev/null
+++ b/testModule/hooks/pre-pivot/mount-tmp.sh
@@ -0,0 +1,38 @@
+# This script only checks if we found a usable partition for the
+# future /tmp. The discovery of that partition is done by udev during
+# the initqueue. If a valid partition is found (either GPT with the label
+# OPENSLX_TMP or MBR with the type 0x44) its path will be written to
+# /tmp/openslx.tmpdisk
+OPENSLX_TMP_DISK_FLAG="/tmp/openslx.tmpdisk"
+
+if [ ! -e "$OPENSLX_TMP_DISK_FLAG" ]; then
+ warn "'$OPENSLX_TMP_DISK_FLAG' not found!"
+ warn "Systemd will manage $NEWROOT/tmp on its own."
+ # no partition for the future /tmp found, just
+ # let systemd manage it then (probably a tmpfs)
+ return 1
+fi
+
+# in /tmp/openslx.disk.tmp is the name of the device
+# to mount as /tmp in the real system
+# meaning we need to mount it to /sysroot/tmp here.
+
+OPENSLX_TMP_DISK_DEV="$(cat $OPENSLX_TMP_DISK_FLAG)"
+
+# sanity check: is the content a block device?
+if [ ! -b "$OPENSLX_TMP_DISK_DEV" ]; then
+ warn "'$OPENSLX_TMP_DISK_DEV' appears not to be a block device!"
+ warn "Systemd will manage $NEWROOT/tmp on its own."
+ return 1
+fi
+
+# all good, keep on
+if ! mount -t auto "$OPENSLX_TMP_DISK_DEV" /sysroot/tmp; then
+ # something else went wrong :(
+ warn "Mounting '$OPENSLX_TMP_DISK_DEV' to '/sysroot/tmp' failed with: $!"
+ warn "Systemd will manage $NEWROOT/tmp on its own."
+ return 1
+fi
+
+# still here? mount worked wohoo
+return 0