当前位置:网站首页>Swap swap partition

Swap swap partition

2022-08-09 09:10:00 Hu Letian

Problems to fix

When compiling doris, I reported such a problem, the memory is insufficient, and my poor cloud has 2G memory, and then I found a solution in Baidu, swap (at first glance, it is very familiar, ha,But the last letter is p not g) swap partition.

virtual memory exhausted: Cannot allocate memory

Details

We have already established a swap partition during the installation of the system. Swap is also called a swap partition, which is a special hard disk space.When the actual memory is not enough (such as my poor 2G memory), the operating system will extract some temporarily unused data from the memory and put it in the swap, so that the memory will have free space.

Use swap to swap partitions, which will exist in almost all operating systems. There is no way, how cheap hard disks are, this is the most affordable.

Operation steps (for linux)

1. Check the memory usage of the system first

# free -m

insert image description here

2. Create a custom directory

# mkdir /opt/images/# rm -rf /opt/images/swap

insert image description here

3. Create a 2GB file

Generally speaking, the capacity of the swap partition should be larger than the size of the physical memory. It is recommended to use twice the memory, but not more than 2GB.

# dd if=/dev/zero of=/opt/images/swap bs=1024 count=2048000

insert image description here

4. Turn the created file into a SWAP partition

# mkswap /opt/images/swap

insert image description here

5. Use this partition file

swapon /opt/images/swap

insert image description here

6. Check whether the partition file is valid

# free -m

insert image description here

7. Remember to close swap after using it

# swapoff /opt/images/swap# rm -f /opt/images/swap
原网站

版权声明
本文为[Hu Letian]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/221/202208090907013635.html