Increasing the swapfile size (especially on a USB SSD attached to my test RPi 3B) is pretty typical when trying to get a Linux box to perform and generally be more stable…
After hanging around on this GitHub issue and watching the progress, I believe there’s a simple and repeatable way to increase the swapfile size.
This solution will survive reboots and upgrades. You also never have to actually open the shell itself.
Please keep in mind that this is strictly for HA OS not Raspberry Pi OS aka Raspbian which has plenty of instructions of how to create and manage swap space.
The simple steps:
- Have a functional HA OS box
- Install an add-on called “SSH & Web Terminal”
- Disable Protection Mode for the add-on
- Under the Configuration for the add-on, change the username and password to something NOT simple because it does validate your entry against the “have I been pwned” database.
- Also under the Configuration for the add-on, replace the init_commands: [] line at the very bottom with the following and start the add-on:
init_commands:
- if [ ! -f /backup/_swap.swap ]; then fallocate -l 2G /backup/_swap.swap && mkswap /backup/_swap.swap && chmod 0600 /backup/_swap.swap && swapon /backup/_swap.swap ; elif [[ ! $(dmesg|grep _swap.swap) = *swap\ on* ]]; then swapon /backup/_swap.swap; fi