Last updated 1 year ago
Check the free space
free -m
Create a partition
dd if=/dev/zero of=$SWAPFILE_DIRECTORY bs=$COUNT count=$SPACE
$COUNT could be 1K \ 1M \ 1G etc.
$COUNT
1K
1M
1G
$SPACE depends on your need, e.g. 1024
$SPACE
1024
Formation
mkswap $SWAPFILE_DIRECTORY chmod -R 600 $SWAPFILE_DIRECTORY
Turn it on
swapon $SWAPFILE_DIRECTORY
Enable it permanently
Open /etc/fstab in the editor.
vim /etc/fstab
Add the line to it
$SWAPFILE_DIRECTORY swap swap defaults 0 0