Skip to content

Commit 73450c8

Browse files
committed
Up memory to 1024 and add swap to low-memory systems
1 parent a395dd9 commit 73450c8

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

Vagrantfile

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Vagrant.configure("2") do |config|
4141
# Display the VirtualBox GUI when booting the machine
4242
vb.gui = false
4343
# Customize the amount of memory on the VM:
44-
vb.memory = "768"
44+
vb.memory = "1024"
4545
end
4646

4747
# Provision
@@ -56,6 +56,22 @@ Vagrant.configure("2") do |config|
5656
5757
grep -q "127.0.0.1 ${VIRTUALHOST}" /etc/hosts || echo "127.0.0.1 ${VIRTUALHOST}" >> /etc/hosts
5858
59+
# Creates a swap file if necessary
60+
RAM=`awk '/MemTotal/ {print $2}' /proc/meminfo`
61+
if [ $RAM -lt 1000000 ] && [ ! -f /swap/swapfile ]; then
62+
echo "================================================================================"
63+
echo "Adding swap"
64+
echo "================================================================================"
65+
echo "This process may take a few minutes. Please wait..."
66+
mkdir /swap
67+
dd if=/dev/zero of=/swap/swapfile bs=1024 count=1000000
68+
chmod 600 /swap/swapfile
69+
mkswap /swap/swapfile
70+
swapon /swap/swapfile
71+
echo "/swap/swapfile swap swap defaults 0 0" >> /etc/fstab
72+
echo "Done."
73+
fi
74+
5975
# Prepare to use APT Proxy
6076
if [ ! -z $APT_PROXY ]; then
6177
if [ ! -f /etc/apt/sources.list-origin ]; then

0 commit comments

Comments
 (0)