Table of Contents
What is swap in centos
Home Operation and Maintenance CentOS What is swap in centos

What is swap in centos

Mar 30, 2022 pm 12:00 PM
centos

In centos, swap means swap partition, which is virtual memory, used to expand temporary data when the physical memory is insufficient; you can virtualize part of the hard disk space into memory, use "free -m" The command can check the current swap space size.

What is swap in centos

The operating environment of this article: centos 7 system, Dell G3 computer.

What is swap in centos

SWAP is virtual memory, used to expand insufficient physical memory and store temporary data. It is similar to virtual memory in Windows. In Windows, only files can be used as virtual memory. Linux can use files or partitions as virtual memory.

First check the current memory and swap space size (default unit is k, -m unit is M):

# free -m
Copy after login

What is swap in centos

Here you can see the total The memory is 503M, and SWAP does not exist.

View swap information, including detailed information about files and partitions

# swapon -s
Copy after login

or

# cat /proc/swaps
Copy after login

If there is none, we need to manually add the swap partition. Note that OPENVZ architecture VPS does not support manual addition of swap partitions.

There are two options for adding swap space: add a swap partition or add a swap file. It is recommended that you add a swap partition; however, if you do not have much free space available, add a swap file.

Add swap file

1. Use the dd command to create a swap file

dd if=/dev/zero of=/home/swap bs=1024 count=1024000
Copy after login

This will create a /home/swap partition file , the size is 1G and can be doubled by itself.

2. Make it into a swap format file:

mkswap /home/swap
Copy after login

3. Then use the swapon command to mount this file partition to the swap partition

swapon /home/swap
Copy after login

Let’s use the free -m command to take a look , and found that there is already a swap partition.

What is swap in centos

But after restarting the system, the swap partition became 0 again.

Recommended tutorial: "centos tutorial"

The above is the detailed content of What is swap in centos. 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 Article Tags

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)

How to input Chinese in centos How to input Chinese in centos Apr 07, 2024 pm 08:21 PM

How to input Chinese in centos

How to read USB disk files in centos7 How to read USB disk files in centos7 Apr 07, 2024 pm 08:18 PM

How to read USB disk files in centos7

How to enter root permissions in centos7 How to enter root permissions in centos7 Apr 02, 2024 pm 08:57 PM

How to enter root permissions in centos7

What to do if you forget your password to log in to centos What to do if you forget your password to log in to centos Apr 07, 2024 pm 07:33 PM

What to do if you forget your password to log in to centos

SCP usage tips-recursively exclude files SCP usage tips-recursively exclude files Apr 22, 2024 am 09:04 AM

SCP usage tips-recursively exclude files

What should I do if I forget my centos username and password? What should I do if I forget my centos username and password? Apr 02, 2024 pm 08:54 PM

What should I do if I forget my centos username and password?

How to enable root permissions in centos7 How to enable root permissions in centos7 Apr 07, 2024 pm 08:03 PM

How to enable root permissions in centos7

What should I do if I forget my centos7 password? What should I do if I forget my centos7 password? Apr 02, 2024 pm 08:51 PM

What should I do if I forget my centos7 password?

See all articles