Skip to content

Instantly share code, notes, and snippets.

@intech
Created October 8, 2018 08:12
Show Gist options
  • Save intech/a28f2f3e051316513c3257597bff080f to your computer and use it in GitHub Desktop.
Save intech/a28f2f3e051316513c3257597bff080f to your computer and use it in GitHub Desktop.
swap+kernel tuning
#!/bin/bash
apt update && apt upgrade -y && apt install -y mc htop curl git
# swap
fallocate -l 4G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo '/swapfile none swap sw 0 0' | tee -a /etc/fstab
swapon --show
# kernel tuning
# sysctl
echo 'vm.swappiness=10' | tee -a /etc/sysctl.d/99-sysctl.conf
echo 'fs.file-max=500000' | tee -a /etc/sysctl.d/99-sysctl.conf
echo 'net.core.somaxconn = 65536' | tee -a /etc/sysctl.d/99-sysctl.conf
# security limits
echo '* hard nofile 32768' | tee -a /etc/security/limits.conf
echo '* soft nofile 32768' | tee -a /etc/security/limits.conf
echo 'root hard nofile 65536' | tee -a /etc/security/limits.conf
echo 'root soft nofile 65536' | tee -a /etc/security/limits.conf
sysctl -p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment