linux添加swap分区
创建:2025-04-27 23:55
更新:2025-04-27 23:55
sudo swapoff /swapfile
sudo fallocate -l 4G /swapfile  # 创建或者扩大文件
sudo chmod 600 /swapfile
sudo mkswap /swapfile        # 重新格式化
sudo swapon /swapfile        # 重新启用
free -h                      # 查看内存及Swap使用情况

编辑/etc/fstab文件,添加以下行实现开机自动挂载

/swapfile none swap sw 0 0