Skip to content

Instantly share code, notes, and snippets.

@zoonderkins
Last active March 17, 2022 17:28
Show Gist options
  • Save zoonderkins/83bfb7a64be1348216c8621a39f72a1b to your computer and use it in GitHub Desktop.
Save zoonderkins/83bfb7a64be1348216c8621a39f72a1b to your computer and use it in GitHub Desktop.
Debian enable SWAP #linux

Debian | Ubuntu enable SWAP

swapon --show

Check free memory and disk

df -h

Enable swap

# Make swap off if exsited
swapoff -a

# Resize the swapfile (increase or decrease). Here let us increase to 2GB (assuming existing one has 1GB space as given in the article)
dd if=/dev/zero of=/var/swapfile bs=1024k count=4000

# 256 Mb
#dd if=/dev/zero of=/var/swapfile bs=512k count=500

# Make swapfile usable
mkswap /var/swapfile

# Make swapon 
swapon /var/swapfile

# change permission to 0600
chmod 0600 /var/swapfile

# Verify the swapfile 
swapon -show

# Make swap file permanent***

echo '/var/swapfile none swap sw 0 0' | tee -a /etc/fstab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment