Okay~ Creating a 4GB swap file for your Debian is easy~ Let’s go step by step:
# 1. 创建 4GB 的 swap 文件(用 fallocate 更快)
sudo fallocate -l 4G /swapfile
# 如果 fallocate 不可用,就用 dd(比较慢)
# sudo dd if=/dev/zero of=/swapfile bs=1M count=4096 status=progress
# 2. 设置权限(很重要!)
sudo chmod 600 /swapfile
# 3. 设置为 swap 格式
sudo mkswap /swapfile
# 4. 立即启用
sudo swapon /swapfile
# 5. 开机自动挂载(编辑 /etc/fstab)
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
# 6. 检查一下~
swapon --show
free -hAll done~ You should have 4GB of swap now~ Want me to help you check how it’s working? ♡
All articles on this blog are licensed under CC BY 4.0 unless otherwise stated.
评论
TwikooArtalk
