How to set up swap virtual memory on Linux cloud server

WBOY
Release: 2023-05-15 23:52:13
forward
1602 people have browsed it

swap 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 will have some setting standards, which are also related to the size of the physical memory.

View memory space: free -h

How to set up swap virtual memory on Linux cloud server

Create swap partition file: dd if=/dev/zero of=/data/swap bs=1M count =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 swap The path for file creation. The above parameters can be modified according to your own needs.

How to set up swap virtual memory on Linux cloud server

mkswap /data/swap #Convert the created file to a swap partition

chmod 600 /data/swap Set permissions

sysctl -p Refresh the system settings to make them effective

How to set up swap virtual memory on Linux cloud server

#swapon /data/swap Start the swap partition virtual memory

free -h View the memory space, the virtual memory in the picture The memory has taken effect

How to set up swap virtual memory on Linux cloud server

echo "/data/swap swap swap defaults 0 0" >> /etc/fstab Add automatic mounting at boot

How to set up swap virtual memory on Linux cloud server

The above is the detailed content of How to set up swap virtual memory on Linux cloud server. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!