Manage and configure Swap partitions in Linux in CentOS

Source: Internet
Author: User
Understand what a swap partition is. Swap is a virtual memory partition in Linux. its main function is to release some space in the physical memory when the physical memory is insufficient, for the current program to use, the space released from the memory has no operation programs, and the released memory will be saved to the swap space. when the write program is running, then read these programs from the swap virtual space for memory usage. In this way, the swap is performed when the system memory is insufficient. For the Linuxweb server

Understanding what is a swap partition


Swap is a virtual memory partition in Linux. its main function is to release some space in the physical memory for use by the current program when the physical memory is insufficient, the space released by the memory has no operations, and the released memory will be stored in the swap space. when the write program is running, then read these programs from the swap virtual space for memory usage. In this way, the swap is performed when the system memory is insufficient. Adjusting swap for Linux web servers can improve the system performance.

The operating system breaks through the limit of physical memory, so that the program can operate more than the physical memory space. the virtual memory is the same as the firewall, so that every process is not disturbed by other programs.

Note that physical memory data is exchanged to swap. If all the memory is stored in swap, it is impossible. Therefore, some of them are directly exchanged to the file system. When this file is read, it is called directly from the file system and not from the swap.

In the early days, we often saw that swap cannot exceed 128 MB. now, our server generally does not have this problem, and the maximum value of swap can be MB. the structure of the swap space file is that the size of each page on the page is the same as that of the memory page. This facilitates swap between the swap space and memory, in earlier versions of Linux, the first page of the Swap space is used as a "bit ing" for all Swap space pages ". This means that each bit on the first page corresponds to a page of Swap space. If this parameter is set to 1, Swap is available on this page. if it is set to 0, this page is a bad block and cannot be used. In this case, the first Swap ing bit should be 0, because the first page of Swap is a ing page.

Therefore, the Linux ing method is canceled.

There are two methods to create a swap

The first method is to add a swap partition when creating the system.

You can also create a swap partition after the system is created, or create a temporary swap. Note that the system can be installed and deployed normally when we create a system without a swap partition, but an error occurs when the system file calls the swa file, so we need swap not to start the system without swap.

View the usage of the current swap resource:

Swapon? S free? M

Related Article

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.