Site Tools


linux:general:swap

Swap

What is Swap?

Create a (temp.) swapfile and add it to swap

Create a swapfile with blocksize 1024 and 2GB

dd if=/dev/zero of=/swap/swapfile bs=1024 count=2M
Format the file and set permissions
mkswap /swap/swapfile
chown root:root /swap/swapfile
chmod 600 /swap/swapfile
Add the swapfile to swap
swapon /swap/swapfile

Remove a swapfile from swap

List the swapfiles

swapon -s
Turn off the swapfile (used swap will be moved to other swap or memory, might take a while)
swapoff /swap/swapfile



linux/general/swap.txt · Last modified: 2019/02/12 14:45 by lunetikk