Created
August 14, 2019 15:25
-
-
Save falexandrou/fefe00e990a093dc8e799fd16f7c8251 to your computer and use it in GitHub Desktop.
Create Swap Ubuntu 16.08
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# How To Add Swap Space on Ubuntu 18.04 | |
# | |
# Check out https://stackmate.io and find out how this (and much more) can be done automatically for you | |
# Before you run this script, please check that swap is not enabled with the following command: | |
# sudo swapon --show | |
# If it shows some output, then you probably don't need to run this script anymore | |
# We're allocating 8GB of swap | |
sudo fallocate -l 8G /swapfile | |
# count = blocksize (bs=1024) * 1024 * 8 (8gb) | |
sudo dd if=/dev/zero of=/swapfile bs=1024 count=8388608 | |
# set the right permissions and enable | |
sudo chmod 600 /swapfile | |
sudo mkswap /swapfile | |
# keep a backup copy of your fstab file | |
sudo cp /etc/fstab /etc/fstab.bak | |
# enable swap on boot time | |
echo '/swapfile swap swap defaults 0 0' | sudo tee -a /etc/fstab |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment