Software >> OS >> Unix >> Linux >>  how to create a file as a swap filesystem and add to you swap space

check current swaps

# cat /proc/swaps

identify the directory to create the file of size for swap e.g. /root
This example we are adding 1GB swap

# dd if=/dev/zero of=/root/swap2 bs=1M count=1024

create swap file system

# mkswap /root/swap2

add swap

# swapon /root/swap2


create permanent entry in /etc/fstab

/root/swap2          swap                 swap       defaults,pri=9        0 0