diff options
author | Jonathan Bauer | 2018-11-12 12:42:55 +0100 |
---|---|---|
committer | Jonathan Bauer | 2018-11-12 17:30:33 +0100 |
commit | 4a26a9fb86d98983c1485c63399fc89d593e8f9c (patch) | |
tree | ad4996aec7b863aa1275104206c3ac11a5068519 /builder/modules.d/slx-partitioner/scripts/generate-fstab-swap.sh | |
parent | [dnbd3-rfs] config: add PXE server info to config (diff) | |
download | systemd-init-4a26a9fb86d98983c1485c63399fc89d593e8f9c.tar.gz systemd-init-4a26a9fb86d98983c1485c63399fc89d593e8f9c.tar.xz systemd-init-4a26a9fb86d98983c1485c63399fc89d593e8f9c.zip |
[slx-partitioner] new module for scratch partition handling
Diffstat (limited to 'builder/modules.d/slx-partitioner/scripts/generate-fstab-swap.sh')
-rw-r--r-- | builder/modules.d/slx-partitioner/scripts/generate-fstab-swap.sh | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/builder/modules.d/slx-partitioner/scripts/generate-fstab-swap.sh b/builder/modules.d/slx-partitioner/scripts/generate-fstab-swap.sh new file mode 100644 index 00000000..5330730a --- /dev/null +++ b/builder/modules.d/slx-partitioner/scripts/generate-fstab-swap.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +# +# Script to create stage4's fstab entry for swap devices +# +# Will use swap partitions of MBR's type '82' or +# GPT UUID '0657fd6d-a4ab-43c4-84e5-0933c84b4f4f' +# +. /etc/openslx + +for swap_dev in \ + $(get_partitions_by_id "82" "0657fd6d-a4ab-43c4-84e5-0933c84b4f4f"); do + + [ -z "$swap_dev" ] && continue + + # Generate swap fstab entry for NEWROOT. Use priority 10 to prefer zram + echo -e "$swap_dev\tswap\t\tswap\t\tx-systemd.makefs,pri=10\t0\t0" \ + >> "$NEWROOT/etc/fstab" + + # check if configured not to wipe any existing filesystem + [ "$SLX_WIPE_SWAP_DEVICE" = "no" ] && continue + + # create a drop-in to wipe the device's filesystem + swap_dev_systemd_escaped="$(tr '/' '-' <<< ${swap_dev:1})" + base_dir="$NEWROOT/etc/systemd/system" + dropin_dir="$base_dir/systemd-mkswap@${swap_dev_systemd_escaped}.service.d" + mkdir -p "$dropin_dir" + cat <<- EOF > "$dropin_dir/wipefs.conf" + [Service] + ExecStartPre=/sbin/wipefs -a %f + EOF +done + +true |