1. 验证环境
妙算manifold2
Ubuntu20.04
2. 步骤
2.1 增加SWAP
# 查看当前SWAP大小 free -m #创建SWAP文件 mkdir /swap cd /swap sudo dd if=/dev/zero of=swapfile bs=1024 count=2000000 # 2000000代表2G sudo mkswap -f swapfile # 激活SWAP sudo swapon swapfile # 再次查看 free -m 的结果 free -m
2.2 将设定写入/etc/fstab
# 如果文本中原先有swap相关语句,可尝试注释掉 /swap/swapfile /swap swap defaults 0 0
2.3 如果只运行上两步重启后SWAP扩展失效
在/etc/rc.local中添加开启swap的命令
# 添加在exit 0 之前 swapon /data/swapfile
2.4 解决Ubuntu16.10后没有rc.local文件
自己创建一个
sudo gedit //etc/rc.local
内容如下:
#!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing. exit 0
执行以下命令确保设置成功
sudo chown root:root /etc/rc.local sudo chmod 755 /etc/rc.local sudo systemctl enable rc-local.service
————————————————