One minute
Expanding Swap Space on Linux [en]
On a Linux system, swap space is used as a virtual memory extension when the system’s physical RAM (Random Access Memory) is fully utilized. When your computer runs out of physical memory because of the applications and processes you’re running, the operating system moves data from the RAM to an area of the hard drive or SSD called swap space
-
Check the Current Swap Space
free -m
orswapon -s
orhtop
-
Create Swap File of size 1GB
# dd if=/dev/zero of=/swap_file bs=1G count=1
Replace the value of ‘bs‘ and ‘count‘ according your requirement. We can also use fallocate command to create a file, example is show below.
#fallocate -l 1G /swap_file
-
Secure the swap file
# chmod 600 /swap_file
-
Enable the Swap Area on Swap File
mkswap /swap_file
-
Add the swap file entry in fstab file
echo "swap_file swap swap defaults 0 0" >> /etc/fstab
-
Extend Swap Space
swapon /swap_file
-
Now verify the swap space
free -m
orswapon -s
orhtop