Skip to content

Instantly share code, notes, and snippets.

@moodysalem
Last active March 21, 2017 13:32
Show Gist options
  • Save moodysalem/4abfdf9b7210c4b1a721 to your computer and use it in GitHub Desktop.
Save moodysalem/4abfdf9b7210c4b1a721 to your computer and use it in GitHub Desktop.
ebextensions swapfile creation script ec2 swap
commands:
000_dd:
test: test ! -e /swapfile
command: dd if=/dev/zero of=/swapfile bs=1M count=2048 && chmod 600 /swapfile
001_mkswap:
command: mkswap /swapfile
ignoreErrors: true
002_swapon:
command: swapon /swapfile
ignoreErrors: true
@moodysalem
Copy link
Author

Creates a 2gb swapfile for use on amazon t2.nano instances

@romanr
Copy link

romanr commented Apr 27, 2016

This will work only 1st time;
swapon /swapfile will work only until restart. swapfile is not added to fstab.
On 2nd run it will detect that /swapfile exists and do nothing.

@moodysalem
Copy link
Author

Changed it to just always try mkswap and swapon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment