1 2 3 4 5 6 7 8 9 10 |
mkdir /swap cd /swap # 创建4G分区文件 dd if=/dev/zero of=swapfile bs=1G count=4 # 修改权限 chmod 600 /swap/swapfile # 设置swap mkswap /swap/swapfile # 启用swap swapon /swap/swapfile |
1 2 3 4 |
[root@datagrad swap]# swapon -s Filename Type Size Used Priority /dev/dm-1 partition 4194300 0 -2 /swap/swapfile file 4194300 0 -3 |
1 2 |
# 开机挂载 echo '/swap/swapfile swap swap defaults 0 0' >> /etc/fstab |
from:https://www.cnblogs.com/leoshi/p/12679962.html