Mastodon Mastodon - Add swap space in Ubuntu
 logo
  • Home 
  • Tags 
  • Blog posts 
  1. Home
  2. Blog posts
  3. Add swap space in Ubuntu

Add swap space in Ubuntu

Posted on June 23, 2021  (Last modified on July 11, 2024) • 1 min read • 120 words
Linux   Linux: Ubuntu  
Linux   Linux: Ubuntu  
Share via

My DigitalOcean Droplet started dropping containers while kswapd ate up CPU cycles like Pacman. Time to add a swap space, or rather a swap file cause I did not want to add a dedicated volume.

# swap usage check - swapon: no output, no use; free: should read "0"
sudo swapon --show
free -h

# as root: create swap (make sure you have enough disk space available)
fallocate -l 4G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

# reboot and check (see first two commands) if swap is available
reboot

Optinonally you can also tune swappiness and cache pressure settings. Both is described in this article’s source (DigitalOcean).

 Set DNS search path on Unifi USG with DHCP
Pi-Hole in Docker 
In case you want to follow me

Here are some links. The further to the right, the less active.

           
(c) Axel Bock | Powered by Hinode.
Link copied to clipboard
Code copied to clipboard