{"id":4449,"date":"2017-08-30T20:43:34","date_gmt":"2017-08-30T20:43:34","guid":{"rendered":"https:\/\/islascruz.org\/blog\/?p=4449"},"modified":"2017-08-30T20:44:43","modified_gmt":"2017-08-30T20:44:43","slug":"quick-tip-vagrant-ram","status":"publish","type":"post","link":"https:\/\/islascruz.org\/blog\/2017\/08\/30\/quick-tip-vagrant-ram\/","title":{"rendered":"Quick tip, vagrant with less RAM"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-4452 aligncenter\" src=\"https:\/\/islascruz.org\/blog\/wp-content\/uploads\/2017\/08\/Screen-Shot-2014-08-13-at-10.30.59-AM-300x167.png\" alt=\"\" width=\"300\" height=\"167\" srcset=\"https:\/\/islascruz.org\/blog\/wp-content\/uploads\/2017\/08\/Screen-Shot-2014-08-13-at-10.30.59-AM-300x167.png 300w, https:\/\/islascruz.org\/blog\/wp-content\/uploads\/2017\/08\/Screen-Shot-2014-08-13-at-10.30.59-AM-768x427.png 768w, https:\/\/islascruz.org\/blog\/wp-content\/uploads\/2017\/08\/Screen-Shot-2014-08-13-at-10.30.59-AM-719x400.png 719w, https:\/\/islascruz.org\/blog\/wp-content\/uploads\/2017\/08\/Screen-Shot-2014-08-13-at-10.30.59-AM.png 800w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/>Vagrant is a popular solution to isolate your development environment, while there are many images to use with vagrant the most popular is an Ubuntu server image cooked by HashiCorp. Although with the current computer specs having a virtual machine that uses 512MB in RAM is almost nothing (I bet Google Chrome is wasting more than that now) if you are like me you don&#8217;t like to have a Virtual Machine wasting resources.<\/p>\n<p>The main reason of why vagrant images uses that amount of RAM is because they don&#8217;t have SWAP, so, if your program\/script is using more RAM than what is in the VM the program\/script is killed.<\/p>\n<p>You can add a SWAP file by using <code>dd<\/code><\/p>\n<pre class=\"\">$ dd if=\/dev\/zero of=\/swapfile bs=1024 count=655360\n$ chmod 00600 \/swapfile\n$ swapon -a<\/pre>\n<p>Then add it to <code>\/etc\/fstab<\/code>. Pretty simple, but you have a big file that may or may not be used in totality.<\/p>\n<p>A better approach is to use <code>swapspace<\/code> daemon, it will create a swap space that will grow\/shrink as needed. You can install the service in your VM if you already have it working or, add this to your <code>Vagrantfile<\/code>\u00a0to have it done automagically.<\/p>\n<pre class=\"\">config.vm.provision \"shell\", inline: \"sudo apt install swapspace -y\"\n<\/pre>\n<p>If you do this with a VM already working just shut it down, use <code>vagrant up --provision<\/code> to run the provision instruction and you are done!.<\/p>\n<p>Having a Swap space allows you to reduce the amount of RAM dedicated to your VM.<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_4449\" class=\"pvc_stats all  \" data-element-id=\"4449\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/islascruz.org\/blog\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Vagrant is a popular solution to isolate your development environment, while there are many images to use with vagrant the most popular is an Ubuntu server image cooked by HashiCorp. Although with the current computer specs having a virtual machine that uses 512MB in RAM is almost nothing (I bet Google Chrome is wasting more [&hellip;]<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_4449\" class=\"pvc_stats all  \" data-element-id=\"4449\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/islascruz.org\/blog\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"author":1,"featured_media":4452,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[239],"tags":[839,838,837,836],"class_list":["post-4449","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tips-and-tricks","tag-development","tag-provision","tag-swap-file","tag-vagrant"],"brizy_media":[],"_links":{"self":[{"href":"https:\/\/islascruz.org\/blog\/wp-json\/wp\/v2\/posts\/4449","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/islascruz.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/islascruz.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/islascruz.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/islascruz.org\/blog\/wp-json\/wp\/v2\/comments?post=4449"}],"version-history":[{"count":5,"href":"https:\/\/islascruz.org\/blog\/wp-json\/wp\/v2\/posts\/4449\/revisions"}],"predecessor-version":[{"id":4455,"href":"https:\/\/islascruz.org\/blog\/wp-json\/wp\/v2\/posts\/4449\/revisions\/4455"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/islascruz.org\/blog\/wp-json\/wp\/v2\/media\/4452"}],"wp:attachment":[{"href":"https:\/\/islascruz.org\/blog\/wp-json\/wp\/v2\/media?parent=4449"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/islascruz.org\/blog\/wp-json\/wp\/v2\/categories?post=4449"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/islascruz.org\/blog\/wp-json\/wp\/v2\/tags?post=4449"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}