回到首页

create vitural memory in Linux

When I intall a python ML library on a small-size-memory server, I encounter a installation error called "run out of memory". Virtual memory helps

Get the state of memory free -m, "Swap" means virtual memory

New a partition file with 1GB dd if=/dev/zero of=/swapfile bs=1024 count=1024000

Set /swapfile as a swap partition file chmod 600 /swapfile && mkswap /swapfile

Activate swap swapon /swapfile

Now swap is created successfully, free -m shows that swap's size is 1000 more than before.

How to remove the swap file:

swapoff /swapfile
rm -rf /swapfile

参考链接:CentOS/Linux服务器的内存不够解决方法

本文创建于2022.3.4/14.30,修改于2022.3.4/14.30

#html #memory