{"id":208,"date":"2013-03-18T22:31:20","date_gmt":"2013-03-19T04:31:20","guid":{"rendered":"http:\/\/www.evermoretechnologies.com\/blog\/?p=208"},"modified":"2013-03-18T22:31:20","modified_gmt":"2013-03-19T04:31:20","slug":"adding-a-swap-file-to-an-ubuntu-12-04-system","status":"publish","type":"post","link":"https:\/\/www.evermoretechnologies.com\/blog\/2013\/03\/adding-a-swap-file-to-an-ubuntu-12-04-system\/","title":{"rendered":"Adding a swap file to an Ubuntu 12.04 system"},"content":{"rendered":"<p>I&#8217;ve started to move myself over to Amazon EC2 servers. I still have some at Rackspace and like a lot of what they have to offer, but I think the seemingly lower cost and flexibility offered with EC2 is becoming better suited to my business. But that&#8217;s just me right now. The problem is, I am trying out their free tier usage right now, and have a micro server. That server has 600MB or RAM and by default comes with no swap. \u00a0A production server, in a perfect world, is never swapping, but a server with only 600MB of RAM could swap with one person looking at a drupal site. \u00a0It does slow the server down a lot, but&#8217;s acceptable for a dev server in my opinion and better than spending twice as much on a dev server that doesn&#8217;t swap. \u00a0After all, I usually develop locally so it&#8217;s more of a client review server than an actual dev server. \u00a0No one wants a server running out of RAM while a client is reviewing a site and mysql just randomly stopping on you.<\/p>\n<p>It only comes with an 8GB hard drive, which I alreadly have 1.3GB used with a single wordpress install, Ubuntu, Apache, PHP, and MariaDB, so using 1GB of that for swap might be risky, but I don&#8217;t imagine having much more than that on a dev server, so I&#8217;m gonna create a 1GB swap file on the hard drive.<\/p>\n<p>First I decided to create a swap directory in the root. Most people put swap on it&#8217;s own partitian at something like \/dev\/sda2, but I&#8217;m just gonna put mine at \/swp.<\/p>\n<p>[code]<br \/>\nsudo mkdir \/swp<br \/>\n[\/code]<\/p>\n<p>Then I create the swap file and set the right permissions.<\/p>\n<p>[code]<br \/>\nsudo fallocate -l 1024m \/swp\/1024MiB.swap<br \/>\nsudo chmod 600 \/swp\/1024MiB.swap<br \/>\n[\/code]<\/p>\n<p>Make it a swapping device.<\/p>\n<p>[code]<br \/>\nsudo mkswap \/swp\/1024MiB.swap<br \/>\n[\/code]<\/p>\n<p>Adding it to the system<\/p>\n<p>[code]<br \/>\nsudo swapon \/swp\/1024MiB.swap<br \/>\n[\/code]<\/p>\n<p>Add it to fstab to make it permanent<\/p>\n<p>[code]<br \/>\nsudo vim \/etc\/fstab<br \/>\n[\/code]<\/p>\n<p>Add this to the end of that file.<\/p>\n<p>[code]<br \/>\n\/swp\/1024MiB.swap  none  swap  sw  0 0<br \/>\n[\/code]<\/p>\n<p>The information for this posting is the contents of this page <a href=\"https:\/\/help.ubuntu.com\/community\/SwapFaq\" target=\"_blank\">https:\/\/help.ubuntu.com\/community\/SwapFaq<\/a> that applied to my situation.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve started to move myself over to Amazon EC2 servers. I still have some at Rackspace and like a lot of what they have to offer, but I think the&#8230; <a href=\"https:\/\/www.evermoretechnologies.com\/blog\/2013\/03\/adding-a-swap-file-to-an-ubuntu-12-04-system\/\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[9,11],"tags":[],"_links":{"self":[{"href":"https:\/\/www.evermoretechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/208"}],"collection":[{"href":"https:\/\/www.evermoretechnologies.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.evermoretechnologies.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.evermoretechnologies.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.evermoretechnologies.com\/blog\/wp-json\/wp\/v2\/comments?post=208"}],"version-history":[{"count":0,"href":"https:\/\/www.evermoretechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/208\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.evermoretechnologies.com\/blog\/wp-json\/wp\/v2\/media?parent=208"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.evermoretechnologies.com\/blog\/wp-json\/wp\/v2\/categories?post=208"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.evermoretechnologies.com\/blog\/wp-json\/wp\/v2\/tags?post=208"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}