Manually clear or refresh Linux SWAP partitions

Source: Internet
Author: User

VPS of XEN and other architectures all have SWAP (SWAP partition ). When the physical memory is close to saturation, the system will automatically dump infrequently used memory files to SWAP. However, when the usage rate of SWAP is 30%, the system performance may be affected.

For VPS or servers with large physical memory, or based on your own server, you can manually disable or refresh the SWAP partition.


I. SWAP switch:
1. Disable SWAP

Generally used for servers with large physical memory


Swapoff-

Run the preceding command in SSH to disable the SWAP partition.


2. Enable SWAP
Swapon-

Run the preceding command in SSH to enable the SWAP partition.


Ii. Refresh SWAP

When the SWAP usage reaches 30%, the system performance may be affected. Therefore, we can execute the above two commands to refresh the SWAP (dumping the data in the SWAP back to the memory, and clear the data in SWAP)


Swapoff-a & swapon-

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

In fact, the principle of refreshing SWAP is to disable swap and restart it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.