This script automates the process of increasing the swap memory to 8GB or any value you set on a Linux system.
-
Download the script:
wget https://raw.githubusercontent.com/CommanderPaladin/Fast-Swap-Increase/main/Fast-Swap-Increase.sh
-
Make the script executable:
chmod +x Fast-Swap-Increase.sh
-
Run the script with root privileges:
sudo ./Fast-Swap-Increase.sh
-
Checks existing swap space: The script displays the current swap space on your system.
-
Turns off all swap: It temporarily disables all active swap spaces.
-
Creates a new swap file: The script creates a new swap file with the size specified by the user (default is 8GB).
-
Sets the correct permissions: Ensures the swap file has the correct permissions for security.
-
Sets up the swap file: Prepares the newly created file to be used as swap space.
-
Enables the swap file: Activates the new swap file for use by the system.
-
Verifies the swap space: Displays the new swap space to confirm the changes.
-
Makes the swap file permanent: Adds the new swap file entry to
/etc/fstabto ensure it is used after reboot.
To customize the swap size, modify the SWAP_SIZE variable in the script:
SWAP_SIZE="8G" # Change this value to your desired swap size, e.g., "16G" for 16GB.- The script creates a backup of the
/etc/fstabfile as/etc/fstab.bakbefore making changes. - It is recommended to review the script and understand its steps before execution.