Skip to content

creating and enabling a swap file

shell
mkdir -p /opt/swapfile/
dd if=/dev/zero of=/opt/swapfile/16GB.swap bs=1024 count=16777216
ls -lh /opt/swapfile/
chmod 600 /opt/swapfile/16GB.swap 
mkswap /opt/swapfile/16GB.swap 
swapon /opt/swapfile/16GB.swap
# 添加自启动
echo '/opt/swapfile/16GB.swap none swap sw 0 0' >> /etc/fstab

Released under the MIT License.