Skip to content

Linux: swap

Marcos Aurélio Silvério edited this page Sep 9, 2020 · 1 revision

New SWAP volume

Create swap file

dd if=/dev/zero of=/swapdir/swapfile bs=1024 count=5485760 # <- 5GB file

Setup swap area

mkswap /swapdir/swapfile

Add mountpoint in /etc/fstab:

/swapdir/swapfile swap swap defaults 0 0

Adjust file permission

chmod 600 /var/swap/swapfile

Enable/Disable SWAP

Enable swap

swapon <device>

swapon -a

Disable swap

swapoff <device>

swapoff -a

Clone this wiki locally