Take the tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

The default Ubuntu AMI does not have swap enabled, but it is not suitable for production use as the machine just crash when it is Out Of Memory.

Are there existing images with swap enabled so I can use without create a custom image?

Thanks.

share|improve this question
add comment

1 Answer

You do not need to create a custom AMI in order to gain swap storage on an Amazon EC2 instance. Rather you can simply add a swap file as outlined in How do I add more swap?:

Swap is generally associated with a swap partition, perhaps because the user is prompted to create a swap partition at the time of installation. In fact, any file can be used as a swapping device, be it a partition or a conventional file. Swap can be added by increasing the size of the swap partition or by adding a swap file. [...] [emphasis mine]

Section Four-step Process to Add Swap File outlines the required steps, which boils down to e.g. (replace /mnt with an appropriate directory of your choice):

sudo fallocate -l 512m /mnt/512MiB.swap
sudo chmod 600 /mnt/512MiB.swap
sudo mkswap /mnt/512MiB.swap
sudo swapon /mnt/512MiB.swap

This won't survive a reboot yet, thus requires you to edit /etc/fstab, e.g.:

sudo nano /etc/fstab

Then add this line at the end of the file:

/mnt/512MiB.swap  none  swap  sw  0 0

Please refer to the linked page for more details and an example session, if need be.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.
{"cc_re__cc_re__cc_by_sa_3_0": ["        <li><a href=\"http://area51.stackexchange.com\" title=\"proposing new sites in the Stack Exchange network\">Area 51</a></li>\r\n                        <li><a href=\"http://careers.stackoverflow.com\">Stack Overflow Careers</a></li>\r\n                    \r\n                </ol>\r\n            </td>\r\n    </tr>\r\n</table>\r\n                </div>\r\n            </div>\r\n\r\n            <div id=\"copyright\">\r\n                site design / logo &#169; 2013 stack exchange inc; user contributions licensed under <a href=\"http://creativecommons.org/licenses/by-sa/3.0/\" rel=\"license\">cc-wiki</a> \r\n with <a href=\"http://blog.stackoverflow.com/2009/06/attribution-required/\" rel=\"license\">attribution required</a>\r\n            </div>\r\n            <div id=\"footer-flair\">\r\n                <a href=\"http://creativecommons.org/licenses/by-sa/3.0/\" class=\"cc-wiki-link\"></a>\r\n            </div>\r\n            <div id=\"svnrev\">\r\n                rev 2013.12.11.1217\r\n            </div>\r\n                <div id=\"additional-notices\">\r\n                    Ubuntu and Canonical are registered tr", "ol>\r\n            </td>\r\n    </tr>\r\n</table>\r\n                </div>\r\n            </div>\r\n\r\n            <div id=\"copyright\">\r\n                site design / logo &#169; 2013 stack exchange inc; user contributions licensed under <a href=\"http://creativecommons.org/licenses/by-sa/3.0/\" rel=\"license\">cc-wiki</a> \r\n with <a href=\"http://blog.stackoverflow.com/2009/06/attribution-required/\" rel=\"license\">attribution required</a>\r\n            </div>\r\n            <div id=\"footer-flair\">\r\n                <a href=\"http://creativecommons.org/licenses/by-sa/3.0/\" class=\"cc-wiki-link\"></a>\r\n            </div>\r\n            <div id=\"svnrev\">\r\n                rev 2013.12.11.1217\r\n            </div>\r\n                <div id=\"additional-notices\">\r\n                    Ubuntu and Canonical are registered trademarks of Canonical Ltd.\r\n                </div>\r\n            \r\n        </div>\r\n    </div>\r\n    <noscript>\r\n        <div id=\"noscript-warning\">Ask Ubuntu works best with JavaScript enabled<img src=\"http://pixel.quantserve.com/pixel/p-c1rF4kxgLUzNc.gif\" alt=\"\" class=\"dno\"></div>\r"], "copyright__copyright__copyright": ["his won't survive a reboot yet, thus requires you to edit /etc/fstab, e.g.:\n\nsudo nano /etc/fstab\n\nThen add this line at the end of the file:\n\n/mnt/512MiB.swap  none  swap  sw  0 0\n\nPlease refer to the linked page for more details and an example session, if need be.\n\nshare|improve this answer\nadd comment\n\nYour Answer\n\n\u00a0\ndiscard\n\nBy posting your answer, you agree to the privacy policy and terms of service.\n\nNot the answer you're looking for? Browse other questions tagged or ask your own question."]}