Created
May 9, 2024 08:16
-
-
Save ravikyada/64254fcf918a98ca82133cce04bd16d9 to your computer and use it in GitHub Desktop.
Create Swap File Inside Debian Server
This file contains 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
#! /usr/bin/bash | |
read -p "Give size of swap you wants to create:" usr_input | |
echo "Your swap memory will be create of size : $usr_input" | |
sudo fallocate -l $usr_input /swapfile | |
sudo chmod 600 /swapfile | |
sudo mkswap /swapfile | |
sudo swapon /swapfile | |
sudo swapon --show | |
sudo cp /etc/fstab /etc/fstab.bak | |
echo '/swap.sh none swap sw 0 0' | sudo tee -a /etc/fstab | |
sudo sysctl vm.swappiness=10 | |
sudo sysctl vm.vfs_cache_pressure=50 | |
echo "vm.vfs_cache_pressure=50" >> /etc/sysctl.conf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment