{"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":[],"aioseo_head":"\n\t\t<!-- All in One SEO Pro 4.9.9 - aioseo.com -->\n\t<meta name=\"description\" content=\"Swap space is defined as a temporary storage that can be used when machine&#039;s memory requirements exceeds the size of the RAM available. Usually size of the swap partition is double of RAM memory. You can add a swap partition or add a swap file. I would recommend you to add a swap partition, but\" \/>\n\t<meta name=\"robots\" content=\"max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n\t<meta name=\"author\" content=\"SupportPRO Admin\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/www.supportpro.com\/blog\/how-to-add-a-swap-file-in-linux\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO Pro (AIOSEO) 4.9.9\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Server Management Tips | SupportPRO Blog\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"How to add a swap file in Linux | Server Management Tips\" \/>\n\t\t<meta property=\"og:description\" content=\"Swap space is defined as a temporary storage that can be used when machine&#039;s memory requirements exceeds the size of the RAM available. Usually size of the swap partition is double of RAM memory. You can add a swap partition or add a swap file. I would recommend you to add a swap partition, but\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/www.supportpro.com\/blog\/how-to-add-a-swap-file-in-linux\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2010-08-09T10:19:00+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2018-10-04T12:36:21+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:title\" content=\"How to add a swap file in Linux | Server Management Tips\" \/>\n\t\t<meta name=\"twitter:description\" content=\"Swap space is defined as a temporary storage that can be used when machine&#039;s memory requirements exceeds the size of the RAM available. Usually size of the swap partition is double of RAM memory. You can add a swap partition or add a swap file. I would recommend you to add a swap partition, but\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.supportpro.com\\\/blog\\\/how-to-add-a-swap-file-in-linux\\\/#article\",\"name\":\"How to add a swap file in Linux | Server Management Tips\",\"headline\":\"How to add a swap file in Linux\",\"author\":{\"@id\":\"https:\\\/\\\/www.supportpro.com\\\/blog\\\/author\\\/managementadmin\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/www.supportpro.com\\\/blog\\\/#organization\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/no-cache.hubspot.com\\\/cta\\\/default\\\/2725694\\\/9d590242-d641-4383-94b4-8cfd62f0af6b.png\",\"@id\":\"https:\\\/\\\/www.supportpro.com\\\/blog\\\/how-to-add-a-swap-file-in-linux\\\/#articleImage\"},\"datePublished\":\"2010-08-09T04:19:00-06:00\",\"dateModified\":\"2018-10-04T06:36:21-06:00\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.supportpro.com\\\/blog\\\/how-to-add-a-swap-file-in-linux\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.supportpro.com\\\/blog\\\/how-to-add-a-swap-file-in-linux\\\/#webpage\"},\"articleSection\":\"Miscellaneous\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.supportpro.com\\\/blog\\\/how-to-add-a-swap-file-in-linux\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.supportpro.com\\\/blog#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.supportpro.com\\\/blog\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.supportpro.com\\\/blog\\\/category\\\/miscellaneous\\\/#listItem\",\"name\":\"Miscellaneous\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.supportpro.com\\\/blog\\\/category\\\/miscellaneous\\\/#listItem\",\"position\":2,\"name\":\"Miscellaneous\",\"item\":\"https:\\\/\\\/www.supportpro.com\\\/blog\\\/category\\\/miscellaneous\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.supportpro.com\\\/blog\\\/how-to-add-a-swap-file-in-linux\\\/#listItem\",\"name\":\"How to add a swap file in Linux\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.supportpro.com\\\/blog#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.supportpro.com\\\/blog\\\/how-to-add-a-swap-file-in-linux\\\/#listItem\",\"position\":3,\"name\":\"How to add a swap file in Linux\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.supportpro.com\\\/blog\\\/category\\\/miscellaneous\\\/#listItem\",\"name\":\"Miscellaneous\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.supportpro.com\\\/blog\\\/#organization\",\"name\":\"SupportPRO\",\"description\":\"SupportPRO Blog\",\"url\":\"https:\\\/\\\/www.supportpro.com\\\/blog\\\/\",\"telephone\":\"+18476076123\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.supportpro.com\\\/blog\\\/author\\\/managementadmin\\\/#author\",\"url\":\"https:\\\/\\\/www.supportpro.com\\\/blog\\\/author\\\/managementadmin\\\/\",\"name\":\"SupportPRO Admin\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/www.supportpro.com\\\/blog\\\/how-to-add-a-swap-file-in-linux\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/13d2f63048d631e03a432375448be5eb7861069df4fef10f0cb1c7b36554c225?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"SupportPRO Admin\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.supportpro.com\\\/blog\\\/how-to-add-a-swap-file-in-linux\\\/#webpage\",\"url\":\"https:\\\/\\\/www.supportpro.com\\\/blog\\\/how-to-add-a-swap-file-in-linux\\\/\",\"name\":\"How to add a swap file in Linux | Server Management Tips\",\"description\":\"Swap space is defined as a temporary storage that can be used when machine's memory requirements exceeds the size of the RAM available. Usually size of the swap partition is double of RAM memory. You can add a swap partition or add a swap file. I would recommend you to add a swap partition, but\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.supportpro.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.supportpro.com\\\/blog\\\/how-to-add-a-swap-file-in-linux\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/www.supportpro.com\\\/blog\\\/author\\\/managementadmin\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/www.supportpro.com\\\/blog\\\/author\\\/managementadmin\\\/#author\"},\"datePublished\":\"2010-08-09T04:19:00-06:00\",\"dateModified\":\"2018-10-04T06:36:21-06:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.supportpro.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.supportpro.com\\\/blog\\\/\",\"name\":\"Server Management Tips\",\"description\":\"SupportPRO Blog\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.supportpro.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO Pro -->\r\n\t\t<title>How to add a swap file in Linux | Server Management Tips<\/title>\n\n","aioseo_head_json":{"title":"How to add a swap file in Linux | Server Management Tips","description":"Swap space is defined as a temporary storage that can be used when machine's memory requirements exceeds the size of the RAM available. Usually size of the swap partition is double of RAM memory. You can add a swap partition or add a swap file. I would recommend you to add a swap partition, but","canonical_url":"https:\/\/www.supportpro.com\/blog\/how-to-add-a-swap-file-in-linux\/","robots":"max-snippet:-1, max-image-preview:large, max-video-preview:-1","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.supportpro.com\/blog\/how-to-add-a-swap-file-in-linux\/#article","name":"How to add a swap file in Linux | Server Management Tips","headline":"How to add a swap file in Linux","author":{"@id":"https:\/\/www.supportpro.com\/blog\/author\/managementadmin\/#author"},"publisher":{"@id":"https:\/\/www.supportpro.com\/blog\/#organization"},"image":{"@type":"ImageObject","url":"https:\/\/no-cache.hubspot.com\/cta\/default\/2725694\/9d590242-d641-4383-94b4-8cfd62f0af6b.png","@id":"https:\/\/www.supportpro.com\/blog\/how-to-add-a-swap-file-in-linux\/#articleImage"},"datePublished":"2010-08-09T04:19:00-06:00","dateModified":"2018-10-04T06:36:21-06:00","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/www.supportpro.com\/blog\/how-to-add-a-swap-file-in-linux\/#webpage"},"isPartOf":{"@id":"https:\/\/www.supportpro.com\/blog\/how-to-add-a-swap-file-in-linux\/#webpage"},"articleSection":"Miscellaneous"},{"@type":"BreadcrumbList","@id":"https:\/\/www.supportpro.com\/blog\/how-to-add-a-swap-file-in-linux\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/www.supportpro.com\/blog#listItem","position":1,"name":"Home","item":"https:\/\/www.supportpro.com\/blog","nextItem":{"@type":"ListItem","@id":"https:\/\/www.supportpro.com\/blog\/category\/miscellaneous\/#listItem","name":"Miscellaneous"}},{"@type":"ListItem","@id":"https:\/\/www.supportpro.com\/blog\/category\/miscellaneous\/#listItem","position":2,"name":"Miscellaneous","item":"https:\/\/www.supportpro.com\/blog\/category\/miscellaneous\/","nextItem":{"@type":"ListItem","@id":"https:\/\/www.supportpro.com\/blog\/how-to-add-a-swap-file-in-linux\/#listItem","name":"How to add a swap file in Linux"},"previousItem":{"@type":"ListItem","@id":"https:\/\/www.supportpro.com\/blog#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/www.supportpro.com\/blog\/how-to-add-a-swap-file-in-linux\/#listItem","position":3,"name":"How to add a swap file in Linux","previousItem":{"@type":"ListItem","@id":"https:\/\/www.supportpro.com\/blog\/category\/miscellaneous\/#listItem","name":"Miscellaneous"}}]},{"@type":"Organization","@id":"https:\/\/www.supportpro.com\/blog\/#organization","name":"SupportPRO","description":"SupportPRO Blog","url":"https:\/\/www.supportpro.com\/blog\/","telephone":"+18476076123"},{"@type":"Person","@id":"https:\/\/www.supportpro.com\/blog\/author\/managementadmin\/#author","url":"https:\/\/www.supportpro.com\/blog\/author\/managementadmin\/","name":"SupportPRO Admin","image":{"@type":"ImageObject","@id":"https:\/\/www.supportpro.com\/blog\/how-to-add-a-swap-file-in-linux\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/13d2f63048d631e03a432375448be5eb7861069df4fef10f0cb1c7b36554c225?s=96&d=mm&r=g","width":96,"height":96,"caption":"SupportPRO Admin"}},{"@type":"WebPage","@id":"https:\/\/www.supportpro.com\/blog\/how-to-add-a-swap-file-in-linux\/#webpage","url":"https:\/\/www.supportpro.com\/blog\/how-to-add-a-swap-file-in-linux\/","name":"How to add a swap file in Linux | Server Management Tips","description":"Swap space is defined as a temporary storage that can be used when machine's memory requirements exceeds the size of the RAM available. Usually size of the swap partition is double of RAM memory. You can add a swap partition or add a swap file. I would recommend you to add a swap partition, but","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/www.supportpro.com\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/www.supportpro.com\/blog\/how-to-add-a-swap-file-in-linux\/#breadcrumblist"},"author":{"@id":"https:\/\/www.supportpro.com\/blog\/author\/managementadmin\/#author"},"creator":{"@id":"https:\/\/www.supportpro.com\/blog\/author\/managementadmin\/#author"},"datePublished":"2010-08-09T04:19:00-06:00","dateModified":"2018-10-04T06:36:21-06:00"},{"@type":"WebSite","@id":"https:\/\/www.supportpro.com\/blog\/#website","url":"https:\/\/www.supportpro.com\/blog\/","name":"Server Management Tips","description":"SupportPRO Blog","inLanguage":"en-US","publisher":{"@id":"https:\/\/www.supportpro.com\/blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"Server Management Tips | SupportPRO Blog","og:type":"article","og:title":"How to add a swap file in Linux | Server Management Tips","og:description":"Swap space is defined as a temporary storage that can be used when machine's memory requirements exceeds the size of the RAM available. Usually size of the swap partition is double of RAM memory. You can add a swap partition or add a swap file. I would recommend you to add a swap partition, but","og:url":"https:\/\/www.supportpro.com\/blog\/how-to-add-a-swap-file-in-linux\/","article:published_time":"2010-08-09T10:19:00+00:00","article:modified_time":"2018-10-04T12:36:21+00:00","twitter:card":"summary","twitter:title":"How to add a swap file in Linux | Server Management Tips","twitter:description":"Swap space is defined as a temporary storage that can be used when machine's memory requirements exceeds the size of the RAM available. Usually size of the swap partition is double of RAM memory. You can add a swap partition or add a swap file. I would recommend you to add a swap partition, but"},"aioseo_meta_data":{"post_id":"354","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"Article","isEnabled":true},"graphs":[]},"schema_type":"default","schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"seo_analyzer_scan_date":"2026-06-17 11:24:01","breadcrumb_settings":null,"limit_modified_date":false,"open_ai":null,"ai":null,"created":"2021-12-10 16:09:08","updated":"2026-06-30 23:05:18"},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t<a href=\"https:\/\/www.supportpro.com\/blog\" title=\"Home\">Home<\/a>\n<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t<a href=\"https:\/\/www.supportpro.com\/blog\/category\/miscellaneous\/\" title=\"Miscellaneous\">Miscellaneous<\/a>\n<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\tHow to add a swap file in Linux\n<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/www.supportpro.com\/blog"},{"label":"Miscellaneous","link":"https:\/\/www.supportpro.com\/blog\/category\/miscellaneous\/"},{"label":"How to add a swap file in Linux","link":"https:\/\/www.supportpro.com\/blog\/how-to-add-a-swap-file-in-linux\/"}],"_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}]}}