1. First check the current swap partition size:
free -m -h
total used free shared buffers cached
Mem: 11G 801M 10G 236K 17M 106M
-/+ buffers/cache: 677M 11G
Swap: 2.0G 0B 2.0G
2. Use the dd command to create a swap partition
# dd if = / dev / zero of = / doiido / swap bs = 1024 count = 6144000
The purpose is to increase the space of 6G (modify the highlight)
3. Format the newly created partition
# mkswap / main / swap
4. Turn the newly created partition into a swap partition
# swapon / main / swap
So far the swap partition has been expanded to 8G:
5. Ensure permanent effect: modify the / etc / fstab file
vim /etc/fstab
Add at the end of the file (the last line)
/home/swap swap swap default 0 0
Just restart.