After experiencing multiple complete system freezes over two months on Arch Linux, I traced the issue to OOM (Out of Memory) events. The system would become completely unresponsive - no mouse, no keyboard, forcing hard reboots.
Root Cause
Checking journalctl revealed the smoking gun:
journalctl -b -1 --no-pager | grep -i "oom"
The OOM killer had terminated systemd-journald and user processes. With 27GB RAM + 16GB swap, memory exhaustion shouldn’t happen often, but when it does, the kernel freezes everything before killing processes.
The Fixes
1. Install earlyoom
Early OOM daemon kills memory-hungry processes before total freeze:
sudo pacman -S earlyoom
sudo systemctl enable --now earlyoom
2. Enable Magic SysRq Keys
Emergency recovery when frozen. Create the config:
echo "kernel.sysrq = 1" | sudo tee /etc/sysctl.d/99-sysrq.conf
sudo sysctl -p /etc/sysctl.d/99-sysrq.conf
When frozen: Hold Alt + SysRq (Print Screen) then slowly type REISUB
- R: Switch keyboard from raw mode
- E: Terminate all processes
- I: Kill all processes
- S: Sync filesystems
- U: Remount read-only
- B: Reboot
3. Reduce Swappiness
Lower swap usage for better performance:
echo "vm.swappiness = 10" | sudo tee /etc/sysctl.d/99-swappiness.conf
echo "vm.vfs_cache_pressure = 50" | sudo tee -a /etc/sysctl.d/99-swappiness.conf
sudo sysctl -p /etc/sysctl.d/99-swappiness.conf
4. Enable systemd-oomd
Additional OOM protection layer:
sudo systemctl enable --now systemd-oomd
Monitoring
Use htop to watch memory usage. Sort by memory with Shift+M. In my case, WinBox was consuming 1GB and needed periodic restarts.
Result
System now has multiple layers of protection:
- earlyoom intervenes before total freeze
- systemd-oomd provides backup protection
- Magic SysRq allows safe emergency reboot
- Reduced swappiness improves responsiveness
No freezes since implementing these changes.