====== Running Linux on Low RAM ======
Keeping a machine with 4-8 GB of soldered RAM responsive: the goal is never hitting the disk-thrash-frozen-UI cliff.
===== earlyoom: Install This First =====
The kernel's own OOM killer waits too long. By the time it fires the desktop has been frozen for minutes. ''earlyoom'' kills the biggest process before that:
sudo apt install earlyoom
sudo systemctl enable --now earlyoom
journalctl -u earlyoom # see what it has killed
Defaults are reasonable: SIGTERM under 10% memory+swap, SIGKILL at 5%. Tune in ''/etc/default/earlyoom'' (''EARLYOOM_ARGS="-m 10 -s 10"'').
===== zram: Compressed RAM Swap =====
sudo apt install zram-tools
zramctl
swapon --show # should list /dev/zram0
Creates a compressed swap device in RAM (~50% of RAM by default, tunable via ''PERCENTAGE'' in ''/etc/default/zramswap''). Swap hits it before disk and it decompresses fast. Paired with ''vm.swappiness=10'', disk swap is a last resort.
===== Know the Budget =====
free -h # watch 'available', not 'free'
ps aux --sort=-%mem | head -10 # biggest users right now
On a light desktop the base system takes ~500 MB; the browser takes everything else. A handful of heavy tabs is usually the whole story.
===== Browser Discipline =====
* Fewer tabs. Container tabs do not save RAM; closed tabs do.
* A tab-unloader extension ("Auto Tab Discard") suspends background tabs.
* ''about:config'' -> ''accessibility.force_disabled'' = ''true'' stops Firefox burning a few hundred MB on features nothing uses.
* ''browser.tabs.unloadOnLowMemory'' = ''true'' (already default on Linux).
* ''extensions.pocket.enabled'' = ''false''.
===== If It Froze Anyway =====
1. Wait ~30 seconds. earlyoom may still be chewing.
2. ''Ctrl+Alt+F3'' -> log in -> ''htop'' -> kill the hog (''F9'' -> SIGTERM).
3. ''Ctrl+Alt+F1'' or F7 back to the desktop.
4. Hard hang: hold ''Alt+PrtSc'' and slowly type ''R E I S U B'', each letter a beat apart. Safer than holding the power button.
===== Do Not Bother =====
* "RAM cleaner" apps: Linux cache is not waste. ''available'' is what counts.
* A bigger disk swapfile: on slow SSDs it just makes the freeze slower, not shorter. Exception: hibernation needs swap at least RAM-sized.
===== See Also =====
* [[hosting:hardware:old_laptops|Old Laptops and Desktops]]
* [[hosting:hardware:power_cooling|Power and Cooling]]
* [[hosting:start|Hosting Guide]]
* [[start|Return to wiki home]]