{"id":354,"date":"2010-08-09T04:19:00","date_gmt":"2010-08-09T10:19:00","guid":{"rendered":"http:\/\/blog.supportpro.com\/2010\/08\/how-to-add-a-swap-file-in-linux\/"},"modified":"2018-10-04T06:36:21","modified_gmt":"2018-10-04T12:36:21","slug":"how-to-add-a-swap-file-in-linux","status":"publish","type":"post","link":"https:\/\/www.supportpro.com\/blog\/how-to-add-a-swap-file-in-linux\/","title":{"rendered":"How to add a swap file in Linux"},"content":{"rendered":"<p>Swap space is defined as a temporary storage\u00a0 that can be used when<br \/>\nmachine&#8217;s memory requirements exceeds the size of the RAM available.<br \/>\nUsually size of the swap partition is double of RAM memory.<br \/>\nYou can add a swap partition or add a swap file. I would recommend you<br \/>\nto add a swap partition, but sometimes isn&#8217;t\u00a0 easy if you do not have<br \/>\nenough free space. This article explains how to add a swap file to a<br \/>\nLinux system.<br \/>\nDetermine the size of the new swap file and multiple by 1024 to find<br \/>\nthe block size. For example, the block size of a 128 MB swap file is<br \/>\n131072.<br \/>\nOpen the shell prompt as root and type the below command.<br \/>\ndd if=\/dev\/zero of=\/swapfile bs=1024 count=131072<br \/>\nSetup the swap file with the following command:<br \/>\nmkswap \/swapfile<br \/>\nTo facilitate swap file immediately but not automatically at boot time.<br \/>\nswapon \/swapfile<br \/>\nAdd the below line in \/etc\/fstab to enable the swap at boot time.<br \/>\n\/swapfile swap swap defaults 0 0<br \/>\nIt will enable the new swap file when the next time system boots.<br \/>\nConfirm newly added swap file system by checking the output of the<br \/>\ncommands cat \/proc\/swaps or free<\/p>\n<p>If you require help, <a href=\"https:\/\/www.supportpro.com\/requestquote.php\">contact SupportPRO Server Admin<\/a><\/p>\n<p style=\"text-align: center;\"><!--HubSpot Call-to-Action Code --><span id=\"hs-cta-wrapper-9d590242-d641-4383-94b4-8cfd62f0af6b\" class=\"hs-cta-wrapper\"><span id=\"hs-cta-9d590242-d641-4383-94b4-8cfd62f0af6b\" class=\"hs-cta-node hs-cta-9d590242-d641-4383-94b4-8cfd62f0af6b\"><!-- [if lte IE 8]><\/p>\n\n\n\n\n\n<div id=\"hs-cta-ie-element\"><\/div>\n\n\n<![endif]--><a href=\"https:\/\/cta-redirect.hubspot.com\/cta\/redirect\/2725694\/9d590242-d641-4383-94b4-8cfd62f0af6b\"><img decoding=\"async\" id=\"hs-cta-img-9d590242-d641-4383-94b4-8cfd62f0af6b\" class=\"hs-cta-img\" style=\"border-width: 0px;\" src=\"https:\/\/no-cache.hubspot.com\/cta\/default\/2725694\/9d590242-d641-4383-94b4-8cfd62f0af6b.png\" alt=\"Server not running properly? Get A FREE Server Checkup By Expert Server Admins - $125 Value\" \/><\/a><\/span><script charset=\"utf-8\" src=\"https:\/\/js.hscta.net\/cta\/current.js\"><\/script><script type=\"text\/javascript\"> hbspt.cta.load(2725694, '9d590242-d641-4383-94b4-8cfd62f0af6b', {}); <\/script><\/span><!-- end HubSpot Call-to-Action Code --><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Swap space is defined as a temporary storage\u00a0 that can be used when machine&#8217;s memory requirements exceeds the size of the RAM available. Usually size of the swap partition is&hellip;<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_lmt_disableupdate":"","_lmt_disable":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-354","post","type-post","status-publish","format-standard","hentry","category-miscellaneous"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts\/354","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/comments?post=354"}],"version-history":[{"count":1,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts\/354\/revisions"}],"predecessor-version":[{"id":3387,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts\/354\/revisions\/3387"}],"wp:attachment":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/media?parent=354"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/categories?post=354"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/tags?post=354"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}