How to fix system freezes when ram usage is high | swap | Manjaro Linux

January 06, 2020

Since installing Manjaro, I've experienced a few system freezes and had to force restart my computer.

I suspected the reason was probably not enough swap space. So I checked the swappiness on my computer, which turned out to be 60. Not knowing how swapping works, I thought a swappiness of 60 meant I had enough swap space.

Turns out swappiness didn't mean what I thought it meant and I didn't have any swap space allocated.

After creating an 8 gig swap file and activating it, my computer doesn't run out of ram anymore because the OS takes advantage of the swap space proactively.

How to create swap space

There are a few ways to create swap space. I'll introduce the simplest one, which I used.

  1. Create swapfile(M = Mebibytes, G = Gibibytes) # fallocate -l 8G /swapfile
  2. Set permissions # chmod 600 /swapfile
  3. After creating the correctly sized file, format it to swap: # mkswap /swapfile
  4. Activate the swap file: # swapon /swapfile
  5. Edit /etc/fstab by adding this line: /swapfile none swap defaults 0 0

Finally, check if you swap space is working htop

htop

If you've activated your swap space successfully, you should see "swap" in your htop.

Reference

https://wiki.archlinux.org/index.php/Swap#Swap_file_creation

Subscribe to my email list

© 2022 ALL RIGHTS RESERVED