Interview Prep/Linux/Storage & Memory

How do you add a swap file?

BeginnerConceptStorage & Memory
Answer
sudo fallocate -l 4G /swapfile      # use dd on filesystems where fallocate swap is unsupported
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
swapon --show
All Linux questions Roadmap: Linux

More on Storage & Memory