Swap size Change
Assuming the current system swap size is 4GB, you want to increase the swap size to 5GB.
The steps are as follows:
View current swap size
Free-h
Increase the 1GBswap size, assuming the file path and name:/snow/swapfile, execute the following command
DD If=/dev/zero of=/snow/swapfile bs=1m count=1024
Create swap, the file size is 1GB after successful creation
Mkswap/snow/swapfile
Activate swap
/usr/sbin/swapon/snow/swapfile
Set the swap security permission to 600
chmod 600/snow/swapfile
Use the free-h command to check that the swap size has been updated successfully
Free-h
If you want to change back to the original swap size, execute the following command
/usr/sbin/swapoff/snow/swapfile
Use free-h again to see that the value of swap has been changed back to the original 4GB Swap-Optimized file/proc/sys/vm/swappiness, the value inside represents the ratio of physical memory. If 20, indicates that physical memory is used for 80% of the time to temporarily adjust the size of the value of the swap space-assuming that the value of 10 to execute the following command
Sysctl vm.swappiness=10
Or
echo >/proc/sys/vm/swappiness
Permanent adjustment:
vim/etc/sysctl.conf Add a line: vm.swappiness=10
Linux-swap Size Change and optimization