Home > Operation and Maintenance > Linux Operation and Maintenance > Introduce two methods to create memory swap space swap

Introduce two methods to create memory swap space swap

齐天大圣
Release: 2020-11-05 16:21:25
Original
2383 people have browsed it

First, let’s introduce the role of swap. Generally, when we install the Linux operating system, the system will create a swap partition by default. Let's take a look at the usage of the swap partition on the server

# free -h
              total        used        free      shared  buff/cache   available
Mem:           992M        630M         68M        264K        293M        198M
Swap:          1.0G         96M        927M
Copy after login

The swap partition size of the server is 1G. This swap partition is created by the system by default. We will increase the capacity of the swap partition on this basis later. .

The swap partition is called the swap partition. As a special hard disk space, it plays the role of memory. When the system memory is not enough, the system will store some of the data in the memory that will not be used temporarily into the swap partition. The advantage of using swap partitions is that hard drives are much cheaper than memory, so this is a very cost-effective way to increase system memory. However, if swap is used frequently, it will greatly affect the running speed of the system. Therefore, the best strategy for using swap partitions is to "prepare for use".

Next, let’s take a look at how to create a swap partition.

Build a swap partition through physical partition

First you need to partition itIntroduce two methods to create memory swap space swap

Next, format it

mkswap /dev/sda5
Copy after login

Then open the new swap partition

Introduce two methods to create memory swap space swapAt this point, the construction of the swap partition is completed. Unlike ordinary partitions, there is no need to mount the swap partition when building it. Just use the command swapon partition name.

Build a swap partition through files

The above method is suitable for unused remaining space on the disk. But if all the disk space is partitioned, how to create a swap partition? We can build a swap partition by making a large file. Although the disk space has been completely allocated, this method can be used as long as there is remaining space in any of the partitions.

Let’s create a large file

Introduce two methods to create memory swap space swap

Next format it

Introduce two methods to create memory swap space swap

Finally turn on swap Partition

Introduce two methods to create memory swap space swap

Today I will introduce two methods to build a swap partition. Generally, the size of the swap partition is recommended to be within 2G. Remember that the role of the swap partition is when the memory is not enough. Use the hard disk space as memory temporarily.

The above is the detailed content of Introduce two methods to create memory swap space swap. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template