[CENTOS] Create SWAP for CentOS7

Check the System for Swap Information

We can see if the system has any configured swap by using swapon, a general-purpose swap utility. With the -s
flag, swapon will display a summary of swap usage and availability on our storage device:

swapon -s

If nothing is returned by the command, then the summary was empty and no swap file exists.

Check Available Storage Space

df -h

Create a Swap File

sudo fallocate -l 4G /swapfile

ls -lh /swapfile

Enable a Swap File

sudo mkswap /swapfile
sudo swapon /swapfile

Make the Swap File Permanent

sudo nano /etc/fstab
At the bottom of the file, you need to add a line that will tell the operating system to automatically use the swap file that you created:
/swapfile swap swap sw 0 0

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容