docs / linux / swap

.swap

linux updated 2025-06-26

sudo swapoff -a sudo fallocate -l 2G /swapfile sudo dd if=/dev/zero of=/swapfile bs=1M count=2048 sudo chmod 600 /swapfile sudo mkswap /swapfile sudo swapon /swapfile echo ‘/swapfile none swap sw 0 0’ | sudo tee -a /etc/fstab

Or manually edit /etc/fstab and ensure this line exists:

textcopy
/swapfile none swap sw 0 0
textcopy
sudo swapon --show
free -h

You should now see your new swap size reflected in the output.