As we know that swap is a sub directory in root hierarchy,And this Swap plays main role when the the total amount of physical RAM memory is full,all the inactive pages are moved from the RAM to the swap space.After sometime again we can have free space in Physical RAM memory and their will no issues in the performance of your system or server.
Swap space can take the form of either a dedicated swap partition or a swap file. In most cases when running CentOS by default in a virtual machine a swap partition is not present so the only option is to create a swap memory.
# free -m total used free shared buff/cache available Mem: 989 739 70 25 179 73 Swap: 0 0 0
sudo dd if=/dev/zero of=/swap bs=1024 count=1048576
1048576+0 records in
1048576+0 records out
1073741824 bytes (1.1 GB) copied, 14.9154 s, 72.0 MB/s
sudo chmod 600 /swap
sudo mkswap /swap
Setting up swapspace version 1, size = 1048572 KiB
no label, UUID=c20c0156-81cb-4ed9-a941-7875f0fae0cd
sudo swapon /swap
vi /etc/fstab
sudo swapon --show
NAME TYPE SIZE USED PRIO
/swap file 1024M 0B -2
sudo free -h total used free shared buff/cache available Mem: 989M 742M 60M 25M 186M 68M Swap: 1.0G 0B 1.0G