blob: bb37d6cf93cc370e1ff3da14de9e5e7e7fb63535 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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 \
$(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
|