swapfile-proxomx.sh
· 532 B · Bash
Raw
#!/bin/bash
# Define swapfile size and path
SWAPFILE_PATH="/var/lib/vz/swapfile"
SWAPFILE_SIZE="64G"
# Create the swapfile with the specified size
fallocate -l $SWAPFILE_SIZE $SWAPFILE_PATH
# Set the correct permissions
chmod 600 $SWAPFILE_PATH
# Set up the swap space
mkswap $SWAPFILE_PATH
# Enable the swapfile
swapon $SWAPFILE_PATH
# Add the swapfile entry to /etc/fstab
echo "$SWAPFILE_PATH none swap sw 0 0" >> /etc/fstab
# Verify the swap is active
swapon --show
echo "64GB swapfile created and mounted successfully."
1 | #!/bin/bash |
2 | |
3 | # Define swapfile size and path |
4 | SWAPFILE_PATH="/var/lib/vz/swapfile" |
5 | SWAPFILE_SIZE="64G" |
6 | |
7 | # Create the swapfile with the specified size |
8 | fallocate -l $SWAPFILE_SIZE $SWAPFILE_PATH |
9 | |
10 | # Set the correct permissions |
11 | chmod 600 $SWAPFILE_PATH |
12 | |
13 | # Set up the swap space |
14 | mkswap $SWAPFILE_PATH |
15 | |
16 | # Enable the swapfile |
17 | swapon $SWAPFILE_PATH |
18 | |
19 | # Add the swapfile entry to /etc/fstab |
20 | echo "$SWAPFILE_PATH none swap sw 0 0" >> /etc/fstab |
21 | |
22 | # Verify the swap is active |
23 | swapon --show |
24 | |
25 | echo "64GB swapfile created and mounted successfully." |
26 |