1
0
Fork 1
Quick Swap increase.
Go to file
colin 95c88f7715 Update swap.sh 2024-09-13 16:46:03 -04:00
README.md Update README.md 2024-09-13 16:43:56 -04:00
swap.sh Update swap.sh 2024-09-13 16:46:03 -04:00

README.md

Swap File Creation Script

This script automatically creates a swap file on your system, allowing you to increase the available virtual memory. It calculates the optimal swap file size based on the available disk space, ensuring that the swap file does not exceed 30GB or 5% of the free disk space, whichever is smaller.

Features

  • Detects the main disk partition used by the system.
  • Calculates the optimal swap file size (up to 30GB or 5% of the free space).
  • Creates and activates a swap file at /swapfile.
  • Optionally persists the swap file across reboots using the --persist flag.
  • Displays the status of the created swap file.

Usage

To use this script, you can execute it directly from the URL without downloading it.

Execute Directly from URL

Run the script directly from the URL using curl and piping to bash:

curl -sSL https://git.nixc.us/colin/swap-increase/raw/branch/main/swap.sh | bash

Persist the Swap File Across Reboots

To ensure the swap file is persisted across reboots, run the script with the --persist flag:

curl -sSL https://git.nixc.us/colin/swap-increase/raw/branch/main/swap.sh | bash -s -- --persist

This will automatically add the swap file to /etc/fstab, so it is activated after a system reboot.

Output

The script will provide the following output:

  • The calculated size of the swap file.
  • Confirmation of swap file creation and activation.
  • Whether the swap file will persist after reboot (based on the --persist flag).
  • Information on the current swap status using swapon --show.

Note

This script requires sudo privileges to create and activate the swap file, as well as to modify the /etc/fstab file for persistence across reboots when using the --persist flag.