How to set up swap partition SWAP in Linux 7.7

How to set up swap partition SWAP in Linux 7.7

The Swap partition of the Linux system, that is, the swap partition, is also commonly called virtual memory. The role of the Swap space can be simply described as: when the system's physical memory is insufficient, it is necessary to release part of the physical memory for use by the currently running program. The released space may come from some programs that have not been operated for a long time. The released space is temporarily saved in the Swap space. When those programs are to be run, the saved data is restored from the Swap to the memory. In this way, the system will only perform swap when the physical memory is insufficient. In fact, Swap adjustment is crucial to the performance of Linux servers, especially Web servers. By adjusting Swap, you can sometimes overcome system performance bottlenecks and save system upgrade costs.

1. Create a swap partition file

[root@devsz wxadmin]# dd if=/dev/zero of=/opt/swapfile bs=1M count=4096 
4096+0 records in
4096+0 records out
4294967296 bytes (4.3 GB) copied, 20.789 s, 207 MB/s

2. Authorize the file

[root@devsz wxadmin]# chmod 600 /opt/swapfile

3. Format the swap partition

[root@devsz wxadmin]# mkswap /opt/swapfile 
Setting up swapspace version 1, size = 4194300 KiB
no label, UUID=bfe83644-0fa0-43f9-bf7e-69f9e24b391f

4. Enable swap partition

[root@devsz wxadmin]# swapon /opt/swapfile

5. Check the swap partition status

[root@devsz wxadmin]# free -m
       total used free shared buff/cache available
Mem: 3789 2682 208 280 898 586
Swap: 4095 0 4095
[root@devsz wxadmin]# 

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • How to create a swap partition file in Linux
  • How to add and increase swap partition in Linux

<<:  Practical method of deleting a row in a MySql table

>>:  Solution to elementui's el-popover style modification not taking effect

Recommend

Introduction to the use of common Dockerfile commands

Table of contents 01 CMD 02 ENTRYPOINT 03 WORKDIR...

Build a Docker private warehouse (self-signed method)

In order to centrally manage the images we create...

Share 10 of the latest web front-end frameworks (translation)

In the world of web development, frameworks are ve...

Detailed explanation of the usage of DECIMAL in MySQL data type

Detailed explanation of the usage of DECIMAL in M...

5 ways to quickly remove the blank space of Inline-Block in HTML

The inline-block property value becomes very usef...

Win10 uses Tsinghua source to quickly install pytorch-GPU version (recommended)

Check whether your cuda is installed Type in the ...

Vue implements sending emoticons in chat box

The specific code for sending emoticons in the vu...

How to use custom tags in html

Custom tags can be used freely in XML files and HT...

Detailed analysis of the chmod command to modify file permissions under Linux

Use the Linux chmod command to control who can ac...

Example code of vue icon selector

Source: http://www.ruoyi.vip/ import Vue from ...

How to receive binary file stream in Vue to realize PDF preview

Background Controller @RequestMapping("/getP...

CSS implements 0.5px lines to solve mobile compatibility issues (recommended)

【content】: 1. Use background-image gradient style...

Draw an iPhone based on CSS3

Result:Implementation Code html <div class=...