Applied on my.knownelement.com 2026-09-03 (founder-approved): /apps.swap2 4G, fstab-persisted, no restarts. Verification + closure note: https://projects.knownelement.com/issues/755#note-13
40 lines
1.1 KiB
Bash
Executable File
40 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
# grow-swap2.sh — add a second 4G swapfile on the Cloudron host [#755]
|
|
# Founder-approved 2026-09-03. Second-file approach: no swapoff, no restart,
|
|
# zero risk to the running fleet. Idempotent — safe to re-run.
|
|
#
|
|
# Applied live on my.knownelement.com 2026-09-03 (result: /apps.swap +
|
|
# /apps.swap2 = 8G total, fstab persisted). Re-runnable on any host that
|
|
# needs the same headroom; set NEW/SIZE_MB to taste.
|
|
set -euo pipefail
|
|
|
|
NEW=/apps.swap2
|
|
SIZE_MB=4096
|
|
|
|
if swapon --show=NAME --noheadings | grep -qx "$NEW"; then
|
|
echo "$NEW already active"
|
|
else
|
|
if [ -e "$NEW" ]; then
|
|
echo "ERROR: $NEW exists but is not active — inspect manually" >&2
|
|
exit 1
|
|
fi
|
|
fallocate -l "${SIZE_MB}M" "$NEW" 2>/dev/null \
|
|
|| dd if=/dev/zero of="$NEW" bs=1M count="$SIZE_MB" status=none
|
|
chmod 600 "$NEW"
|
|
mkswap "$NEW"
|
|
swapon "$NEW"
|
|
echo "activated $NEW"
|
|
fi
|
|
|
|
if grep -q "^$NEW " /etc/fstab; then
|
|
echo "fstab entry already present"
|
|
else
|
|
printf '%s none swap sw 0 0\n' "$NEW" >> /etc/fstab
|
|
echo "fstab entry added"
|
|
fi
|
|
|
|
echo "--- swapon ---"
|
|
swapon --show
|
|
echo "--- free ---"
|
|
free -h
|