创建swap文件
mkdir /swap
dd if=/dev/zero of=/swap/swapfile bs=1M count=4096
mkswap /swap/swapfile
chmod 600 /swap/swapfile
swapon /swap/swapfile
修改fstab
root@huaweiyun:~# cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/vda1 during curtin installation
UUID=2a7c600d-e70b-4b54-988c-2b35ef164622 / ext4 defaults 0 1
# 添加下面这行
/swap/swapfile swap swap defaults 0 0