Add swap_adder.sh
This commit is contained in:
13
swap_adder/swap_adder.sh
Executable file
13
swap_adder/swap_adder.sh
Executable file
@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Ask if a swap file is needed
|
||||
read -p "Do you want to add a swap file? (y/n): " add_swap
|
||||
if [[ "$add_swap" == "y" ]]; then
|
||||
read -p "Enter the size of the swap file (e.g., 1G, 512M): " swap_size
|
||||
sudo fallocate -l "$swap_size" /swapfile
|
||||
sudo chmod 600 /swapfile
|
||||
sudo mkswap /swapfile
|
||||
sudo swapon /swapfile
|
||||
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
|
||||
echo "Swap file of size $swap_size created."
|
||||
fi
|
||||
3
swap_adder/swap_adder.sh.save
Executable file
3
swap_adder/swap_adder.sh.save
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
Reference in New Issue
Block a user