-
Allocate swap
sudo fallocate -l 1G /swapfile
-
Alternate allocation
sudo dd if=/dev/zero of=/swapfile bs=1024 count=1048576
-
Perms
sudo chmod 600 /swapfile
-
Setup swap
sudo mkswap /swapfile
-
Enable swap
sudo swapon /swapfile
-
/etc/fstab entry
/swapfile swap swap defaults 0 0
-
Show swap
sudo swapon --show
-
Adjust swapiness #60 good for all, put lower value for production servers
cat /proc/sys/vm/swappiness
-
Setup swapiness
sudo sysctl vm.swappiness=10
-
/etc/sysctl.conf
vm.swappiness=10
-
Remove swap
sudo swapoff -v /swapfile
-
Delete swap file
sudo rm /swapfile
Created
September 12, 2023 08:24
-
-
Save lemajes/7f6c2844038e5bd514718a02ea911542 to your computer and use it in GitHub Desktop.
[SWAP 101] Swap 101 #linux #swap #101
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment