diff options
Diffstat (limited to 'modules.d/dnbd3-rootfs')
-rwxr-xr-x | modules.d/dnbd3-rootfs/hooks/s3-mount-root.sh | 14 | ||||
-rwxr-xr-x | modules.d/dnbd3-rootfs/hooks/s3-write-fstab.sh | 15 | ||||
-rwxr-xr-x | modules.d/dnbd3-rootfs/module-setup.sh | 2 |
3 files changed, 23 insertions, 8 deletions
diff --git a/modules.d/dnbd3-rootfs/hooks/s3-mount-root.sh b/modules.d/dnbd3-rootfs/hooks/s3-mount-root.sh index 2f5fc15f..78410fce 100755 --- a/modules.d/dnbd3-rootfs/hooks/s3-mount-root.sh +++ b/modules.d/dnbd3-rootfs/hooks/s3-mount-root.sh @@ -1,5 +1,6 @@ #!/bin/bash +type emergency_shell >/dev/null 2>&1 || source /lib/dracut-lib.sh # $NEWROOT source "/etc/openslx" cnt=0 @@ -14,23 +15,20 @@ done ret=99 if [ -n "$SLX_MOUNT_ROOT_OPTIONS" ]; then # Always prefer mount options mandated by server + echo "Mounting with provided options: $SLX_MOUNT_ROOT_OPTIONS" 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 + echo "Trying optimized ext4 mount options..." + mount -t ext4 "$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... + echo "Trying default mount with no options..." mount "$SLX_DNBD3_DEVICE_COW" "$NEWROOT" ret=$? fi fi -(( ret != 0 )) && exit $ret - -if ! [ -e "$NEWROOT/etc/fstab.keep" ] && ! grep -qF 'NODELETE' "$NEWROOT/etc/fstab"; then - echo "" > "$NEWROOT/etc/fstab" -fi - -exit 0 +exit $ret diff --git a/modules.d/dnbd3-rootfs/hooks/s3-write-fstab.sh b/modules.d/dnbd3-rootfs/hooks/s3-write-fstab.sh new file mode 100755 index 00000000..8cb252cd --- /dev/null +++ b/modules.d/dnbd3-rootfs/hooks/s3-write-fstab.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +type emergency_shell >/dev/null 2>&1 || source /lib/dracut-lib.sh # $NEWROOT + +if [ -e "/etc/fstab" ]; then + echo "Copying /etc/fstab from initrd" + cp -f "/etc/fstab" "$NEWROOT/etc/fstab" || exit 1 +elif ! [ -e "$NEWROOT/etc/fstab.keep" ] && ! grep -qF 'NODELETE' "$NEWROOT/etc/fstab"; then + echo "Wiping stage4 fstab" + echo "" > "$NEWROOT/etc/fstab" || exit 1 +else + echo "Keeping stage4 fstab untouched" +fi + +exit 0 diff --git a/modules.d/dnbd3-rootfs/module-setup.sh b/modules.d/dnbd3-rootfs/module-setup.sh index 33ab065a..bff931f7 100755 --- a/modules.d/dnbd3-rootfs/module-setup.sh +++ b/modules.d/dnbd3-rootfs/module-setup.sh @@ -159,6 +159,8 @@ install() { --after "initrd-root-device.target" \ --requires "initrd-root-device.target" \ --wbefore "initrd-root-fs.target" + slx_service "s3-write-fstab" "Write final fstab for stage4" \ + --after "s3-mount-root" # Copy systemd services to new root (so they don't get killed after # switch_root) inst_hook pre-pivot 90 \ |