sudo -i
truncate -s 0 swapfile
chattr +C swapfile # for btrfs
fallocate -l 2G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
sysctl vm.swappiness=10
sudo sysctl vm.vfs_cache_pressure=50
# persistent change
cp /etc/fstab /etc/fstab.bak
echo '/swapfile none swap sw 0 0' | tee -a /etc/fstab
echo 'vm.vfs_cache_pressure=50' | tee -a /etc/sysctl.conf
echo 'vm.swappiness = 10' | tee -a /etc/sysctl.conf