summaryrefslogtreecommitdiffstats
path: root/modules.d/dnbd3-rootfs/hooks/s3-mount-root.sh
diff options
context:
space:
mode:
Diffstat (limited to 'modules.d/dnbd3-rootfs/hooks/s3-mount-root.sh')
-rwxr-xr-xmodules.d/dnbd3-rootfs/hooks/s3-mount-root.sh39
1 files changed, 39 insertions, 0 deletions
diff --git a/modules.d/dnbd3-rootfs/hooks/s3-mount-root.sh b/modules.d/dnbd3-rootfs/hooks/s3-mount-root.sh
new file mode 100755
index 00000000..11ea46e3
--- /dev/null
+++ b/modules.d/dnbd3-rootfs/hooks/s3-mount-root.sh
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+type emergency_shell >/dev/null 2>&1 || source /lib/dracut-lib.sh
+
+source "/etc/openslx"
+
+cnt=0
+while ! [ -b "$SLX_DNBD3_DEVICE_COW" ] \
+ || ! [ "$( blockdev --getsize64 "$SLX_DNBD3_DEVICE_COW" 2> /dev/null )" -gt 0 ]; do
+ (( ++cnt > 20 )) && break
+ (( cnt % 5 == 0 )) && echo "Waiting for block device...."
+ usleep 100000
+ (( cnt > 10 )) && udevadm trigger && udevadm settle
+done
+
+ret=99
+if [ -n "$SLX_MOUNT_ROOT_OPTIONS" ]; then
+ # Always prefer mount options mandated by server
+ mount "$SLX_DNBD3_DEVICE_COW" "$NEWROOT" $SLX_MOUNT_ROOT_OPTIONS
+ ret=$?
+else
+ # Let's guess it's ext4, tune for maximum performance as we don't care about recoverability
+ mount "$SLX_DNBD3_DEVICE_COW" "$NEWROOT" -o data=writeback,barrier=0,commit=60,noinit_itable,discard,noatime
+ ret=$?
+ if (( ret != 0 )); then
+ # Just try with no options and hope for the best...
+ mount "$SLX_DNBD3_DEVICE_COW" "$NEWROOT"
+ ret=$?
+ fi
+fi
+
+(( ret != 0 )) && exit $ret
+
+if [ -n "$SLX_GENERATE_FSTAB_SCRIPT" ]; then
+ eval "$SLX_GENERATE_FSTAB_SCRIPT"
+else
+ echo "" > "$NEWROOT/etc/fstab"
+fi
+true