Skip to content

Commit e72c5eb

Browse files
committed
aguia-pescadora-bravo (#16): Swap de 12GB, swappiness 10/100 & vfs_cache_pressure 50/100
1 parent 6f683a6 commit e72c5eb

File tree

3 files changed

+132
-2
lines changed

3 files changed

+132
-2
lines changed

logbook/aguia-pescadora-bravo.sh

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,56 @@ sudo apt install language-pack-pt language-pack-pt-base
8181

8282
sudo update-locale LANG=pt_PT.utf8
8383

84-
### Criar Swap__________________________________________________________________
85-
84+
### Criar Swap & ajusta Swappiness______________________________________________
85+
# Se o sistema operacional ficar sem memória ram suficiênte, ele pode ter falha
86+
# crítica. Diferente de windows, no Linux swap precisa ser especificada
87+
# explícitamente. No caso da aguia-pescadora-bravo, tanto por estabilidade do
88+
# sistema como para explicitamente permitir que usuários possam fazer tarefas
89+
# eventualmente intensivas, vamos por 12GB de Swap (A RAM desse sistema é 8GB)
90+
#
91+
# AVISO: apesar de:
92+
#
93+
# 1) os discos SSD da OVH tenham uma performance fantástica
94+
# 2) não seria incomum o uso de swap em tarefas pontuais de data science
95+
# 3) todo usuário de aguia-pescadora-bravo esteja ciente que
96+
# eventualmente colegas podem usar usar muita CPU e muita RAM
97+
# e que não poderão reclamar de lentidão apps e afins
98+
#
99+
# é uma boa prática de vizinhança
100+
#
101+
# 1) se for rodar tarefas pesadas por várias horas, esteja online
102+
# 2) se puder escolher horários que menos pessoas estão usando, melhor
103+
# 3) feche seus programas quando parar de usar, e se algo der errado
104+
# avise algum admin para dar um reinstart na máquina
105+
106+
## Cria um /swapfile de 12GB
107+
# @see https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-ubuntu-18-04
108+
sudo fallocate -l 12G /swapfile
109+
sudo chmod 600 /swapfile
110+
ls -lh /swapfile
111+
sudo mkswap /swapfile
112+
sudo swapon /swapfile
113+
114+
sudo cp /etc/fstab /etc/fstab.bak
115+
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
116+
117+
## Ajusta swappness (tendência do SO a fazer swap)
118+
# 100 = preferir fazer swap agressivamente (deixar memoria ram livre)
119+
# 0 = só fazer swap em caso de urgência (deixa RAM o mais ocupada possivel)
120+
cat /proc/sys/vm/swappiness
121+
# O padrão vem com 60, vamos por em 10 (para so faze swap em casos mais criticos)
122+
123+
sudo sysctl vm.swappiness=10
124+
125+
vim /etc/sysctl.conf
126+
# Adciona 'vm.swappiness=10' (sem aspas) no final do arquivo
127+
128+
## Cache Pressure
129+
cat /proc/sys/vm/vfs_cache_pressure
130+
# 100, vamos alterar para 50
131+
132+
vim /etc/sysctl.conf
133+
# Adciona 'vm.vfs_cache_pressure=50' (sem aspas) no final do arquivo
86134

87135
#------------------------------------------------------------------------------#
88136
# SEÇÃO: Benchmark do sistema #
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
LABEL=cloudimg-rootfs / ext4 defaults 0 0
2+
LABEL=UEFI /boot/efi vfat defaults 0 0
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#
2+
# /etc/sysctl.conf - Configuration file for setting system variables
3+
# See /etc/sysctl.d/ for additional system variables.
4+
# See sysctl.conf (5) for information.
5+
#
6+
7+
#kernel.domainname = example.com
8+
9+
# Uncomment the following to stop low-level messages on console
10+
#kernel.printk = 3 4 1 3
11+
12+
##############################################################3
13+
# Functions previously found in netbase
14+
#
15+
16+
# Uncomment the next two lines to enable Spoof protection (reverse-path filter)
17+
# Turn on Source Address Verification in all interfaces to
18+
# prevent some spoofing attacks
19+
#net.ipv4.conf.default.rp_filter=1
20+
#net.ipv4.conf.all.rp_filter=1
21+
22+
# Uncomment the next line to enable TCP/IP SYN cookies
23+
# See http://lwn.net/Articles/277146/
24+
# Note: This may impact IPv6 TCP sessions too
25+
#net.ipv4.tcp_syncookies=1
26+
27+
# Uncomment the next line to enable packet forwarding for IPv4
28+
#net.ipv4.ip_forward=1
29+
30+
# Uncomment the next line to enable packet forwarding for IPv6
31+
# Enabling this option disables Stateless Address Autoconfiguration
32+
# based on Router Advertisements for this host
33+
#net.ipv6.conf.all.forwarding=1
34+
35+
36+
###################################################################
37+
# Additional settings - these settings can improve the network
38+
# security of the host and prevent against some network attacks
39+
# including spoofing attacks and man in the middle attacks through
40+
# redirection. Some network environments, however, require that these
41+
# settings are disabled so review and enable them as needed.
42+
#
43+
# Do not accept ICMP redirects (prevent MITM attacks)
44+
#net.ipv4.conf.all.accept_redirects = 0
45+
#net.ipv6.conf.all.accept_redirects = 0
46+
# _or_
47+
# Accept ICMP redirects only for gateways listed in our default
48+
# gateway list (enabled by default)
49+
# net.ipv4.conf.all.secure_redirects = 1
50+
#
51+
# Do not send ICMP redirects (we are not a router)
52+
#net.ipv4.conf.all.send_redirects = 0
53+
#
54+
# Do not accept IP source route packets (we are not a router)
55+
#net.ipv4.conf.all.accept_source_route = 0
56+
#net.ipv6.conf.all.accept_source_route = 0
57+
#
58+
# Log Martian Packets
59+
#net.ipv4.conf.all.log_martians = 1
60+
#
61+
62+
###################################################################
63+
# Magic system request Key
64+
# 0=disable, 1=enable all
65+
# Debian kernels have this set to 0 (disable the key)
66+
# See https://www.kernel.org/doc/Documentation/sysrq.txt
67+
# for what other values do
68+
#kernel.sysrq=1
69+
70+
###################################################################
71+
# Protected links
72+
#
73+
# Protects against creating or following links under certain conditions
74+
# Debian kernels have both set to 1 (restricted)
75+
# See https://www.kernel.org/doc/Documentation/sysctl/fs.txt
76+
#fs.protected_hardlinks=0
77+
#fs.protected_symlinks=0
78+
#
79+
vm.swappiness=10
80+
vm.vfs_cache_pressure=50

0 commit comments

Comments
 (0)