


Introduce two methods to create memory swap space swap
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
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 it
Next, format it
mkswap /dev/sda5
Then open the new swap partition
At 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
Next format it
Finally turn on swap Partition
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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Linux swap space is a special hard disk space used for memory expansion in the Linux operating system. Its role is to provide additional virtual memory to ensure the normal operation of the system. Proper configuration and management of swap space can help maintain the stability and performance of the system regularly. It is the responsibility of the system administrator to monitor the usage of Swap space and adjust the size of the swap space according to the actual situation.

Turn off SWAPSWAP is a memory swapping technology. Copy the memory to the preset disk space in pages. Memory is fast and expensive. Disks are slow and cheap. Generally, the more SWAP is used, the lower the system performance will be. Redis is an in-memory database, and using SWAP will cause rapid performance degradation. It is recommended to leave enough memory and turn off SWAP.

What is swap? Swapspace is an area on the disk, which can be a partition, a file, or a combination of them. To put it simply, when the system's physical memory is tight, Linux will save infrequently accessed data in the memory to swap, so that the system has more physical memory to serve each process, and when the system needs to access the content stored on swap When, the data on the swap is loaded into the memory. This is what we often call swapout and swapin. Why is swap needed? To answer this question, we need to answer what benefits swap brings to us. For some large applications (such as LibreOffice, videoeditor

If you want to add a swap partition in a Linux system, how do you add it? Let’s take a look at the detailed tutorial below. 1. First, click "Launcher" on the dock bar, find "Deepin Terminal" and run it. 2. Then set a password for the root user. Because the installation process is for the administrator user, the root password is not set. sudopasswdroot3. After the setting is completed, execute the su command to switch to the root user. 4. Execute the following command to generate a swap file in the root directory, count sets the number of blocks, and bs sets the block size to generate a 4G swap. ddif=/dev/zeroof=/swapfilecou

Swap memory mainly means that when the physical memory is not enough, the system will enable part of the hard disk space to serve as server memory. By default, swap memory has some setting standards, which are also related to the size of physical memory. Check the memory space: free-h Create swap partition file: ddif=/dev/zeroof=/data/swapbs=1Mcount=4096 Code explanation: bs is the size of the block, count is the number of blocks, it is known that bs=1M, count= 4096, 1M*1024=4G swap partition virtual memory, /data/swap is the path where the swap file is created, the above parameters can be modified according to your own needs. m

During the use of deepin, some users find that their system lacks a swap partition and don’t know what to do. In fact, in most cases, it doesn’t matter if we don’t have a swap partition. If necessary, you can also manually create and mount a swap partition. to solve. What to do if deepin does not have a swap partition: 1. During installation 1. If there is no swap when we install the system partition, as shown in the figure. 2. At this time, you can exit the installation program first, then select swap under the file system item, and then install it. 2. Swap1 cannot be found. If we created a swap partition during installation but cannot find it when using it, it may be a resolution problem. 2. At this time we can try to enter the grub interface, in

Step 1: Confirm the status of swap. Use the following command to check the memory status: free-m. If the result shows that swap is 0, it means that swap does not exist and you need to create swap. totalusedfreesharedbufferscachedMem:1840161422615361340-/+buffers/cache:2381602Swap:000 or you can use this command to view it. If no results are output, swap does not exist. swapon-s Step 2: Create swap We use the following command to create a swap file with a size of 2GB. ddif=/dev/zeroof=/

View the current Swap file location and size To view the location of the swap file or partition currently in use, you can use the swapon command. Execute the following command: sudoswapon --show This will display all active swap space, including its type (such as file or partition), size, usage, and location. If you are only interested in file paths or partition paths, you can view the same information through the /proc/swaps file: cat /proc/swaps This will list all swap spaces on the system, including their locations. Setting up a new Swap space On Manjaro (an Arch-based Linux distribution), you can use a variety of methods to set up a swap space.
