Loading... ### 一、准备工作 执行“`sudo swapon -s`”或“`sudo swapon --show`”命令,查看是否已经存在swap file  ### 二、修改swap file ```shell # 如果第一步存在swapfile则需要先禁用 sudo swapoff /swapfile # 修改swap空间的大小为2G sudo dd if=/dev/zero of=/swapfile bs=1M count=2048 # 设置swapfile权限 sudo chmod 600 /swapfile # 验证权限命令 ls -lh /swapfile # 标记swap file为交换空间 sudo mkswap /swapfile # 启用swapfile sudo swapon /swapfile ``` ### 三、永久化Swap文件 ```shell sudo cp /etc/fstab /etc/fstab.bak echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab ``` <hr class="content-copyright" style="margin-top:50px" /><blockquote class="content-copyright" style="font-style:normal"><p class="content-copyright">版权属于:LiangKe.org</p><p class="content-copyright">本文链接:<a class="content-copyright" href="https://liangke.org/79.html">https://liangke.org/79.html</a></p></blockquote> 最后修改:2020 年 07 月 24 日 12 : 24 AM © 允许规范转载 赞赏 如果觉得我的文章对你有用,请随意赞赏 ×Close 赞赏作者 扫一扫支付 支付宝支付 微信支付