{"id":122,"date":"2010-05-31T23:33:16","date_gmt":"2010-06-01T03:33:16","guid":{"rendered":"http:\/\/bitc.bme.emory.edu\/~lzhou\/blogs\/?p=122"},"modified":"2010-05-31T23:33:16","modified_gmt":"2010-06-01T03:33:16","slug":"linux-add-a-swap-file","status":"publish","type":"post","link":"https:\/\/csic.som.emory.edu\/~lzhou\/blogs\/?p=122","title":{"rendered":"Linux: add a swap file"},"content":{"rendered":"<p>To add a swap file:<\/p>\n<ol type=\"1\">\n<li>Determine the size of the new swap file and multiple by 1024 to \t  determine the block size. For example, the block size of a 64 MB swap \t  file is 65536.<\/li>\n<li>At a shell prompt as root, type the following command with \t  <tt>count<\/tt> being equal to the desired block size:<br \/>\n<table border=\"0\" width=\"90%\" bgcolor=\"#e0e0e0\">\n<tbody>\n<tr>\n<td>\n<pre><tt>dd if=\/dev\/zero of=\/swapfile bs=1024 count=65536<\/tt><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<li>Setup the swap file with the command:<br \/>\n<table border=\"0\" width=\"90%\" bgcolor=\"#e0e0e0\">\n<tbody>\n<tr>\n<td>\n<pre><tt>mkswap \/swapfile<\/tt><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<li>To enable the swap file immediately but not automatically at \t  boot time:<br \/>\n<table border=\"0\" width=\"90%\" bgcolor=\"#e0e0e0\">\n<tbody>\n<tr>\n<td>\n<pre><tt>swapon \/swapfile<\/tt><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<li>To enable it at boot time, edit <tt>\/etc\/fstab<\/tt> to include:<br \/>\n<table border=\"0\" width=\"90%\" bgcolor=\"#e0e0e0\">\n<tbody>\n<tr>\n<td>\n<pre><tt>\/swapfile               swap                    swap    defaults        0 0<\/tt><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>The next time the system boots, it will enable the new swap \t    file.<\/li>\n<li>After adding the new swap file and enabling it, make sure it is \t    enabled by viewing the output of the command <tt>cat \t      \/proc\/swaps<\/tt> or <tt>free<\/tt>.<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>To add a swap file: Determine the size of the new swap file and multiple by 1024 to determine the block size. For example, the block size of a 64 MB swap file is 65536. At a shell prompt as root, type the following command with count being equal to the desired block size: dd [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21,3],"tags":[],"class_list":["post-122","post","type-post","status-publish","format-standard","hentry","category-computer-tips","category-mri-technical-support","post-blog"],"_links":{"self":[{"href":"https:\/\/csic.som.emory.edu\/~lzhou\/blogs\/index.php?rest_route=\/wp\/v2\/posts\/122","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/csic.som.emory.edu\/~lzhou\/blogs\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/csic.som.emory.edu\/~lzhou\/blogs\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/csic.som.emory.edu\/~lzhou\/blogs\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/csic.som.emory.edu\/~lzhou\/blogs\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=122"}],"version-history":[{"count":0,"href":"https:\/\/csic.som.emory.edu\/~lzhou\/blogs\/index.php?rest_route=\/wp\/v2\/posts\/122\/revisions"}],"wp:attachment":[{"href":"https:\/\/csic.som.emory.edu\/~lzhou\/blogs\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=122"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/csic.som.emory.edu\/~lzhou\/blogs\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=122"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/csic.som.emory.edu\/~lzhou\/blogs\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=122"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}