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

Vue recursively implements three-level menu

This article example shares the specific code of ...

A brief discussion on JS prototype and prototype chain

Table of contents 1. Prototype 2. Prototype point...

Docker uses the nsenter tool to enter the container

When using Docker containers, it is more convenie...

How to use sed command to efficiently delete specific lines of a file

Preface Normally, if we want to delete certain li...

How to add fields to a large data table in MySQL

Preface I believe everyone is familiar with addin...

Solution to win10 without Hyper-V

Are you still looking for a way to enable Hyper-v...

Detailed explanation of JavaScript stack and copy

Table of contents 1. Definition of stack 2. JS st...

Detailed explanation of how to manually deploy a remote MySQL database in Linux

1. Install mysql Run the following command to upd...

Example of using #include file in html

There are two files a.htm and b.htm. In the same d...

Website Design Experience Summary of Common Mistakes in Website Construction

Reminder: Whether it is planning, designing, or de...

On Visual Design and Interaction Design

<br />In the entire product design process, ...

How to use Font Awesome 5 in Vue development projects

Table of contents Install Dependencies Configurat...

Simple web design concept color matching

(I) Basic concepts of web page color matching (1) ...