How to manually clear or refresh the SWAP partition of Linux

  

XEN and other architecture VPS have SWAP (swap partition). When the physical memory is close to saturation, the system will automatically dump the infrequent memory files into SWAP, but the SWAP usage rate may have a certain impact on system performance when it reaches 30%. For VPS or servers with large physical memory, or depending on your own server, consider manually turning off or refreshing the SWAP partition.

First, SWAP switch: 1, close SWAP is generally used for large physical memory server
swapoff -a


Execute the above command in SSH, you can close SWAP partition . 2. Open SWAP
swapon -a


Execute the above command in SSH to open the SWAP partition.

Second, refresh SWAP when the SWAP occupancy rate is as high as 30%, may have a certain impact on system performance, so in appropriate circumstances, we can perform the above two commands to refresh the SWAP (will SWAP data) Dump back to memory and empty the data in SWAP)
swapoff -a && swapon -a


Execute the above command in SSH to achieve the corresponding purpose.

In fact, the principle of refreshing SWAP is to close swap and then restart.

Copyright © Windows knowledge All Rights Reserved