forked from zuzu59/deploy-proxmox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall_swapfile_4GB.sh
executable file
·42 lines (32 loc) · 1016 Bytes
/
install_swapfile_4GB.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
# Petit script pour créer facilement swapfile de 1GB sur une machine virtuelle
# z210822.2232, zf221224.0930
# source: https://support.rackspace.com/how-to/create-a-linux-swap-file/
# source: https://www.digitalocean.com/community/questions/how-to-change-swap-size-on-ubuntu-14-04
echo ""
echo "ATTENTION, ce script doit tourner en mode 'sudo' !"
echo ""
# erase old swap file
swapoff /swapfile
rm /swapfile
#create the swap space 4GB
echo "Creating 4GB swap space in /swapfile..."
fallocate -l 4G /swapfile
ls -lh /swapfile
#secure the swapfile
echo "Securing the swapfile..."
chown root:root /swapfile
chmod 0600 /swapfile
ls -lh /swapfile
#turn the swapfile on
echo "Turning the swapfile on..."
mkswap /swapfile
swapon /swapfile
echo "Verifying..."
swapon -s
grep -i --color swap /proc/meminfo
echo "Adding swap entry to /etc/fstab"
echo -e "\n/swapfile none swap sw 0 0" >> /etc/fstab
echo "Result: "
cat /etc/fstab
echo " ****** We are done !!! ********"