How to Create a pagefile/swap (CentOS, Red Hut)

First let’s check how much swap space is available in our system:
# swapon-s

To run free:
# free

After we learned that the swap space we don’t have, let us find out how much free space there is on your hard drive. To do this, use the command:
# df-h
I have a server with 512 MB of RAM will create a paging file on the same size:
# dd if =/dev/zero of =/swapfile bs = 1 m count = 500
# mkswap/swapfile
# swapon/swapfile

Let’s check what we have:
# swapon-s

Edit in any way convenient for you/etc/fstab file. For example like this:
# nano/etc/fstab

And add the following line:
/swapfile swap swap defaults 0 0

Save the configuration file.

Next we need to configure permissions for read-write performance, as well as the owner of the swap file:
# chown root: root/swapfile
# chmod 0600/swapfile