Last active
June 9, 2016 19:28
-
-
Save MarkGavalda/595f62f0099d6fcd2859 to your computer and use it in GitHub Desktop.
Create a swap file on Ubuntu of 1GB with 15% swappiness
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
#!/bin/bash | |
# Creating a 1G swap file | |
sudo dd if=/dev/zero of=/swapfile bs=1M count=1024 | |
# Changing the file permission | |
sudo chmod 600 /swapfile | |
sudo chown root:root /swapfile | |
# Formatting the file as a swap type | |
sudo mkswap /swapfile | |
# Adding the swap file to the system initialization | |
sudo echo /swapfile none swap defaults 0 0 | sudo tee -a /etc/fstab | |
# Adjusting swappiness to 15% | |
sudo bash -c "echo 'vm.swappiness = 15' >> /etc/sysctl.conf" | |
# Activating the swap file | |
sudo swapon -a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment