GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m'# No Color
# Check if the script is run with sudo if [[ $EUID -ne 0 ]]; then echo"This script must be run as root (using sudo)." exit 1 fi
SWAP_FILE="/swapfile"
create_swap() { read -p "Enter the desired size of the swap file in MB: " SWAP_SIZE_MB
echo"Creating a swap file of ${SWAP_SIZE_MB}MB. This may take a while..." fallocate -l ${SWAP_SIZE_MB}M ${SWAP_FILE} if [ $? -ne 0 ]; then echo"Error creating swap file. Ensure you have enough free disk space and fallocate is installed." return 1 fi
chmod 600 ${SWAP_FILE} mkswap ${SWAP_FILE} if [ $? -ne 0 ]; then echo"Error setting up swap area." rm -f ${SWAP_FILE} return 1 fi
swapon ${SWAP_FILE} if [ $? -ne 0 ]; then echo"Error enabling swap." rm -f ${SWAP_FILE} return 1 fi
# Add to /etc/fstab to make it permanent echo"${SWAP_FILE} swap swap defaults 0 0" | sudo tee -a /etc/fstab > /dev/null echo"Swap file created and enabled successfully." }
adjust_swap() { if ! swapon --show | grep -q "${SWAP_FILE}"; then echo"No swap file (${SWAP_FILE}) is currently active to adjust. Please create one first or check if SWAP_FILE variable is correctly set." return 1 fi
swapoff ${SWAP_FILE} if [ $? -ne 0 ]; then echo"Error disabling swap." return 1 fi
read -p "Enter the new desired size of the swap file in MB: " NEW_SWAP_SIZE_MB
echo"Resizing swap file to ${NEW_SWAP_SIZE_MB}MB. This may take a while..." rm -f ${SWAP_FILE}# Remove the old swap file fallocate -l ${NEW_SWAP_SIZE_MB}M ${SWAP_FILE} if [ $? -ne 0 ]; then echo"Error creating new swap file." return 1 fi chmod 600 ${SWAP_FILE} mkswap ${SWAP_FILE} if [ $? -ne 0 ]; then echo"Error setting up new swap area." rm -f ${SWAP_FILE} return 1 fi swapon ${SWAP_FILE} if [ $? -ne 0 ]; then echo"Error enabling new swap." rm -f ${SWAP_FILE} return 1 fi
echo"Swap file resized and enabled successfully." }
delete_swap() { if ! swapon --show | grep -q "${SWAP_FILE}"; then echo"No swap file (${SWAP_FILE}) is currently active to delete. Please create one first or check if SWAP_FILE variable is correctly set." return 1 fi
swapoff ${SWAP_FILE} if [ $? -ne 0 ]; then echo"Error disabling swap." return 1 fi
# Remove from /etc/fstab sudo sed -i "/${SWAP_FILE} swap swap/d" /etc/fstab rm -f ${SWAP_FILE} echo"Swap file deleted successfully." }
Basic System Information: --------------------------------- Uptime : 0 days, 1 hours, 3 minutes Processor : Intel(R) Xeon(R) Platinum 8171M CPU @ 2.60GHz CPU cores : 1 @ 2095.079 MHz AES-NI : ✔ Enabled VM-x/AMD-V : ❌ Disabled RAM : 892.9 MiB Swap : 4.0 GiB Disk : 65.8 GiB Distro : Ubuntu 22.04.5 LTS Kernel : 6.8.0-1021-azure VM Type : MICROSOFT IPv4/IPv6 : ✔ Online / ❌ Offline
IPv4 Network Information: --------------------------------- ISP : Microsoft Corporation ASN : AS8075 Microsoft Corporation Host : Microsoft Azure Cloud (eastasia) Location : Hong Kong, Central and Western District (HCW) Country : Hong Kong
iperf3 Network Speed Tests (IPv4): --------------------------------- Provider | Location (Link) | Send Speed | Recv Speed | Ping ----- | ----- | ---- | ---- | ---- Clouvider | London, UK (10G) | 792 Mbits/sec | 1.06 Gbits/sec | 187 ms Eranium | Amsterdam, NL (100G) | 809 Mbits/sec | 1.24 Gbits/sec | 203 ms Uztelecom | Tashkent, UZ (10G) | 623 Mbits/sec | 847 Mbits/sec | 263 ms Leaseweb | Singapore, SG (10G) | 863 Mbits/sec | 5.34 Gbits/sec | 36.1 ms Clouvider | Los Angeles, CA, US (10G) | 829 Mbits/sec | 1.16 Gbits/sec | 154 ms Leaseweb | NYC, NY, US (10G) | 756 Mbits/sec | 1.08 Gbits/sec | 225 ms Edgoo | Sao Paulo, BR (1G) | 469 Mbits/sec | 688 Mbits/sec | 306 ms
Geekbench 6 Benchmark Test: --------------------------------- Test | Value | Single Core | 572 Multi Core | 315 Full Test | https://browser.geekbench.com/v6/cpu/10660333