Skip to content

Instantly share code, notes, and snippets.

@lancewf
Created June 12, 2020 15:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lancewf/ef786778111435187c141bbbaaff07c9 to your computer and use it in GitHub Desktop.
Save lancewf/ef786778111435187c141bbbaaff07c9 to your computer and use it in GitHub Desktop.
Add a swap file to a vm
sudo fallocate -l 1G /swapfile
sudo dd if=/dev/zero of=/swapfile bs=1024 count=1048576
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo "/swapfile swap swap defaults 0 0" >> /etc/fstab
mount -a
or
fallocate -l 1G /swapfile && dd if=/dev/zero of=/swapfile bs=1024 count=1048576 && chmod 600 /swapfile && mkswap /swapfile && swapon /swapfile && echo "/swapfile swap swap defaults 0 0" >> /etc/fstab && mount -a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment