Last active
April 19, 2018 15:32
-
-
Save dertin/9432c21951909771288b8a61b57e1e4d to your computer and use it in GitHub Desktop.
Create swap file on AWS EC2 t2.micro 1gb
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 | |
sudo dd if=/dev/zero of=/swap bs=1M count=1024 | |
sudo mkswap /swap | |
sudo chmod 600 /swap | |
sudo swapon /swap | |
sudo cp -iv /etc/fstab{,-$(date '+%y%m%d%H%M%S').bak} | |
sudo nano /etc/fstab | |
# add line | |
# /swap swap swap defaults 0 0 | |
sudo sysctl vm.swappiness=10 | |
sudo sysctl vm.vfs_cache_pressure=50 | |
cat /proc/sys/vm/swappiness | |
cat /proc/sys/vm/vfs_cache_pressure | |
sudo nano /etc/sysctl.conf | |
# add lines: | |
# vm.swappiness=10 | |
# vm.vfs_cache_pressure=50 | |
# Disable access time logging | |
sudo nano /etc/fstab | |
# change "errors=remount-ro" to "noatime,errors=remount-ro" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment