Home>Article>Operation and Maintenance> How to set up swap virtual memory on Linux cloud server
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
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.
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
#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 echo "/data/swap swap swap defaults 0 0" >> /etc/fstab Add automatic mounting at bootThe 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!