-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path005-minimal-ram
More file actions
executable file
·28 lines (21 loc) · 951 Bytes
/
005-minimal-ram
File metadata and controls
executable file
·28 lines (21 loc) · 951 Bytes
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
#!/bin/bash
# Various fixes for very small VMs
# Mainly this is just Swap file hacks so NPM doesn't kill itself when searching in <512mb RAM
source common
INIT status "Minimal Server Setup"
ISMINIMAL=`INIT ask --prompt "Is this server a tiny VM server with RAM < 512mb? (y|n)" --default "y"`
if [ "$ISMINIMAL" != "y" ]; then
exit 0
fi
# Size in GB of the swap file to set up. Must be a whole number
# Webpack faults if total RAM size is less than 4gb so 4 is a good number here
SIZEGB=4
INIT status "Setting up ${SIZEGB}gb Swap file"
sudo touch /var/swap-${SIZEGB}gb.img
sudo chmod 0600 /var/swap-${SIZEGB}gb.img
sudo dd if=/dev/zero of=/var/swap-${SIZEGB}gb.img bs=1024k count=${SIZEGB}000
sudo mkswap /var/swap-${SIZEGB}gb.img
sudo swapon /var/swap-${SIZEGB}gb.img
echo "/var/swap-${SIZEGB}gb.img none swap sw 0 0" | sudo tee -a /etc/fstab >/dev/null
INIT status "Setting up system Swappiness"
sudo sysctl -w vm.swappiness=30