How to manage swap partitions under Linux configuration

Source: Internet
Author: User
Tags linux

Understand what a swap partition is

Swap is a virtual memory partition under Linux, his main role is that when physical memory is not enough, it is necessary to release some of the space in physical memory, so that the current program to use, these memory freed space has no operational procedures, these freed memory will be saved into the swap space, Wait until the program is running, and then read the programs from the swap virtual space to memory for use. This is when the system memory is not enough to exchange. When it comes to Linux Web servers, adjusting swap can improve the performance of the system.

Now the operating system has broken the physical memory limit, so that the program can operate more than the physical memory space, virtual memory like a firewall, so that each process is not interfered by other programs.

What we need to be aware of is that all of the physical memory data is swapped into swap, and if all of the memory is in swap to the point it is impossible, a portion of it is exchanged directly to the file system. When this file is read, call the program file directly from the file system without calling from swap.

In the early days it was often observed that swap could not exceed 128M, Now our server generally does not exist this problem can swap to 2048M most. The structure of the swap space file is the size of each page of paging and the size of the memory page is the same, the advantage is convenient swap space and memory exchange between the old version of Linux to achieve swap space, the first page of swap space as A "bit map" for all swap pages. This means that each bit of the first page corresponds to a page of swap space. If this is 1, it means that this page swap is available, and if it is 0, it means that the page is a bad block and cannot be used. So the first swap map bit should be 0 because the first page swap is the mapping page.

So the Linux mapping method is canceled.

There are two ways to create a swap generally

The first method is to add a swap partition when you create the system

Another is to create a swap partition after the system has been created, or create a temporary swap. What we need to be aware of is that when we create the system we do not have the swap partition is also able to install the deployment system normally, only when the system file calls SWA file will be wrong, so we need to swap is not without swap does not necessarily start up the system.

To view the usage of the current swap resource:

Swapon–s free–m

Let's go through two examples to do the following

How do we create a swap partition when we don't have enough swap?

1, to determine that there is enough hard drive, here we add a new hard drive

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.