First, let’s introduce the role of swap. Generally, when we have installed 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
The size of the swap partition of this 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, which acts as a special hard disk space and acts as a memory. When the system memory is not enough, the system will store some data in the memory that will not be used temporarily in the swap partition. The advantage of using the swap partition is that the price of the hard disk is far cheaper than the memory, so this is a very economical way to increase the system memory. However, if swap is used frequently, it will greatly affect the operating speed of the system. Therefore, the best usage strategy for the swap partition is “preparation and not use”.
Next, let’s take a look at how to create a swap partition.
Construct swap partition through physical partition
First of all, you need to partition
Today, I introduced two methods to build a swap partition. Generally, the size of the swap partition is recommended to be within 2G. Remember that the function of the swap partition is to use the hard disk space as memory when the memory is not enough.
The above is the detailed content of the two methods to create memory swap space, please pay attention to other related articles on 1024programmer.com for more information!