What is swap in centos
Mar 30, 2022 pm 12:00 PMIn 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.
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
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
or
# cat /proc/swaps
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
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
3. Then use the swapon command to mount this file partition to the swap partition
swapon /home/swap
Let’s use the free -m command to take a look , and found that there is already a swap partition.
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!

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

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

How to read USB disk files in centos7

How to enter root permissions in centos7

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

SCP usage tips-recursively exclude files

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

How to enable root permissions in centos7

What should I do if I forget my centos7 password?
