adding SWAP to UmbrelOS v.1.1.2 to avoid strict RAM limits

In my miniPC RAM is 4GB. After brave installations of 5 apps from a store it became so slow that response to any ssh command became endless.
After checking with ChatGPT4 if there is a swap, I found that it is not available in the default installation script for 1.1.2.
After it was added the Umbrel behaviour became much more responsive and friendly. Based in the results here is the standard upgrade procedure. I would recommend to add it to the installation for the next Umbrel versions as well.

  • Create the Swap File:
    bash
    sudo fallocate -l 2G /swapfile

    If fallocate is not available, use:
    bash
    sudo dd if=/dev/zero of=/swapfile bs=1M count=2048

  • Set the Correct Permissions:
    bash
    sudo chmod 600 /swapfile

  • Set Up the Swap Space:
    bash
    sudo mkswap /swapfile

  • Enable the Swap File:
    bash
    sudo swapon /swapfile

  • Verify Swap Activation:
    bash
    sudo swapon --show

  • Make the Swap File Permanent: Add the swap file entry to /etc/fstab:
    bash
    sudo nano /etc/fstab

    Add the following line to the file:
    /swapfile none swap sw 0 0
    Save and exit the editor.

  • Confirm the Configuration: Reboot the system to ensure the changes persist and verify the swap space again:
    bash
    sudo reboot

2 Likes

Thank you. The lack of swap space is annoying. I have a separate M2 drive I’d like to use. Currently it is impossible to sync bitcoin, electrs at the same time on a 4gb machine. Constant crashes requiring a power cycle to restart.

Before umbrel was an ‘OS’ I ran it on my own Ubuntu Server and never had problems, now, nothing but problems.

How can we get your suggestion in a next version of umbrel? Otherwise the problems will resurface after any update pushed to the machine.

Updating to the initial message:

There were several issues identified overtime. Finally I found the optimal configuration that is stable and efficient running of the apps

Bitcoin node, Electrs, Lightning node, Seafile

with low CPU % (variations between 3%-70%,usially below 30%) and RAM below 2,5 GB for 3 weeks without any issues.

Recommendations:

  1. Use the swapfile size equal to existing RAM size i.e.`

sudo fallocate -l 4G /swapfile

  1. Set the swappiness value = 30

cat /proc/sys/vm/swappiness

echo ‘vm.swappiness=30’ | sudo tee -a /etc/sysctl.conf

  1. Note that each new UmbrelOS update cleans this customized configuration and you need to introduce it again each time using sudo.

It would be good for all users if Umbrel developers could add this swapfile configuration to each update for at least 4 GB RAM !!!

2 Likes