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

Nov 05, 2020 am 09:49 AM
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
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!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What is linux swap space What is linux swap space Jul 18, 2023 am 11:58 AM

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.

What is the use of turning off SWAP in Redis? What is the use of turning off SWAP in Redis? May 27, 2023 am 10:30 AM

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.

How to solve the problem of high Linux Swap space utilization How to solve the problem of high Linux Swap space utilization May 27, 2023 pm 12:37 PM

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

Steps and methods to add swap partition - Linux System Guide Steps and methods to add swap partition - Linux System Guide Jan 03, 2024 pm 07:10 PM

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

How to set up swap virtual memory on Linux cloud server How to set up swap virtual memory on Linux cloud server May 15, 2023 pm 11:52 PM

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

What should I do if deepin does not have a swap partition? What should I do if deepin does not have a swap partition? What should I do if deepin does not have a swap partition? What should I do if deepin does not have a swap partition? Feb 29, 2024 am 10:10 AM

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

How to set up swap on Linux cloud server How to set up swap on Linux cloud server May 18, 2023 pm 11:55 PM

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=/

Linux partition expansion tips for adjusting Swap space size Linux partition expansion tips for adjusting Swap space size Feb 29, 2024 am 11:43 AM

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.

See all articles