Skip to content

Instantly share code, notes, and snippets.

@jamesbee
Last active August 29, 2015 14:24
Show Gist options
  • Save jamesbee/8b42ba3f9971b76ba531 to your computer and use it in GitHub Desktop.
Save jamesbee/8b42ba3f9971b76ba531 to your computer and use it in GitHub Desktop.

Revisions

  1. jamesbee revised this gist Jul 15, 2015. 1 changed file with 11 additions and 10 deletions.
    21 changes: 11 additions & 10 deletions create-swap.sh
    Original file line number Diff line number Diff line change
    @@ -1,14 +1,15 @@
    #! /bin/bash

    sudo -i
    echo "Create '/swapfile'"
    sudo fallocate -l "$1G" /swapfile
    sudo chmod 600 /swapfile
    sudo mkswap /swapfile
    sudo swapon /swapfile
    fallocate -l "$1G" /swapfile
    chmod 600 /swapfile
    mkswap /swapfile
    swapon /swapfile

    echo ""
    echo "Swap status:"
    sudo swapon -s
    swapon -s
    echo ""

    echo ""
    @@ -17,12 +18,12 @@ free -m
    echo ""

    echo "Mount swap to fstab."
    sudo echo '/swapfile none swap sw 0 0' >> /etc/fstab
    echo '/swapfile none swap sw 0 0' >> /etc/fstab

    echo "Set swapniess to 10"
    sudo sysctl vm.swappiness=10
    sudo echo vm.swappiness=10 >> /etc/sysctl.conf
    sysctl vm.swappiness=10
    echo vm.swappiness=10 >> /etc/sysctl.conf

    echo "Set vfs cache pressure to 50"
    sudo sysctl vm.vfs_cache_pressure=50
    sudo echo vm.vfs_cache_pressure = 50 >> /etc/sysctl.conf
    sysctl vm.vfs_cache_pressure=50
    echo vm.vfs_cache_pressure = 50 >> /etc/sysctl.conf
  2. jamesbee revised this gist Jul 15, 2015. 1 changed file with 6 additions and 4 deletions.
    10 changes: 6 additions & 4 deletions create-swap.sh
    Original file line number Diff line number Diff line change
    @@ -6,11 +6,13 @@ sudo chmod 600 /swapfile
    sudo mkswap /swapfile
    sudo swapon /swapfile

    echo "Swap status:\n"
    echo ""
    echo "Swap status:"
    sudo swapon -s
    echo ""

    echo "Mem status:\n"
    echo ""
    echo "Mem status:"
    free -m
    echo ""

    @@ -19,8 +21,8 @@ sudo echo '/swapfile none swap sw 0 0' >> /etc/fstab

    echo "Set swapniess to 10"
    sudo sysctl vm.swappiness=10
    echo vm.swappiness=10 >> /etc/sysctl.conf
    sudo echo vm.swappiness=10 >> /etc/sysctl.conf

    echo "Set vfs cache pressure to 50"
    sudo sysctl vm.vfs_cache_pressure=50
    echo vm.vfs_cache_pressure = 50 >> /etc/sysctl.conf
    sudo echo vm.vfs_cache_pressure = 50 >> /etc/sysctl.conf
  3. jamesbee created this gist Jul 15, 2015.
    26 changes: 26 additions & 0 deletions create-swap.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    #! /bin/bash

    echo "Create '/swapfile'"
    sudo fallocate -l "$1G" /swapfile
    sudo chmod 600 /swapfile
    sudo mkswap /swapfile
    sudo swapon /swapfile

    echo "Swap status:\n"
    sudo swapon -s
    echo ""

    echo "Mem status:\n"
    free -m
    echo ""

    echo "Mount swap to fstab."
    sudo echo '/swapfile none swap sw 0 0' >> /etc/fstab

    echo "Set swapniess to 10"
    sudo sysctl vm.swappiness=10
    echo vm.swappiness=10 >> /etc/sysctl.conf

    echo "Set vfs cache pressure to 50"
    sudo sysctl vm.vfs_cache_pressure=50
    echo vm.vfs_cache_pressure = 50 >> /etc/sysctl.conf