#!/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 \ $(slx-tools dev_find_partitions "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" = "yes" ] || 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