{"id":432,"date":"2013-10-30T12:16:00","date_gmt":"2013-10-30T12:16:00","guid":{"rendered":"https:\/\/opstree.com\/blog\/\/2013\/10\/30\/how-to-create-an-extra-swap-space-using-file-system\/"},"modified":"2026-01-08T12:36:20","modified_gmt":"2026-01-08T07:06:20","slug":"how-to-create-an-extra-swap-space-using-file-system","status":"publish","type":"post","link":"https:\/\/opstree.com\/blog\/2013\/10\/30\/how-to-create-an-extra-swap-space-using-file-system\/","title":{"rendered":"How to create an extra swap space using file system"},"content":{"rendered":"<div dir=\"ltr\" style=\"text-align: left;\">\n<p>Sometimes you feel constrained due to the the RAM limit of your system especially when you are running heavy duty software\u2019s, in this blog I&#8217;ll talk about how you can overcome this problem by hav\u200cing an extra swap space to give you extra computing power<\/p>\n<p>First of all you can execute <i>swapon<\/i> command to check how much swap space you already have in your system<br \/>\n<i>$ swapon -s<br \/>\nFilename\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 Type\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 Size\u00a0\u00a0\u00a0 Used\u00a0\u00a0\u00a0 Priority<br \/>\n\/dev\/sda5\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 partition\u00a0\u00a0\u00a0 8130556\u00a0\u00a0\u00a0 44732\u00a0\u00a0\u00a0 -1<\/i><\/p>\n<p>The above output gives you an indication that you already have a swap space at partition \/dev\/sda5. The numbers under &#8220;Size&#8221; and &#8220;Used&#8221; are in kilobytes. Though I have considerable amount of swap space configured on my system :), let&#8217;s continue and try to create a new swap using file system. Before starting with creation of swap space let&#8217;s make sure that I&#8217;ve enough disk space available in my system<\/p>\n<p><i>$df -h<br \/>\nFilesystem\u00a0\u00a0\u00a0\u00a0\u00a0 Size\u00a0 Used Avail Use% Mounted on<br \/>\n\/dev\/sda3\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 448G\u00a0 123G\u00a0 303G\u00a0 29% \/<br \/>\nudev\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1.9G\u00a0 4.0K\u00a0 1.9G\u00a0\u00a0 1% \/dev<br \/>\ntmpfs\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 767M\u00a0\u00a0 40M\u00a0 727M\u00a0\u00a0 6% \/run<br \/>\nnone\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 5.0M\u00a0\u00a0\u00a0\u00a0 0\u00a0 5.0M\u00a0\u00a0 0% \/run\/lock<br \/>\nnone\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1.9G\u00a0 804K\u00a0 1.9G\u00a0\u00a0 1% \/run\/shm<\/i><\/p>\n<p>So I&#8217;ve a powerful system with 303G of disk space still available, that means I have a liberty of creating a swap space of my liking. I&#8217;ll user the <a href=\"http:\/\/en.wikipedia.org\/wiki\/Dd_%28Unix%29\" target=\"_blank\" rel=\"noopener\"><i><b>data dump(dd) <\/b><\/i><\/a>command to my supplementary swap file, make sure that you would be running this command using root user.<br \/>\n<i>$dd if=\/dev\/zero of=\/home\/sandy\/extraswap bs=1M count=512<br \/>\n512+0 records in<br \/>\n512+0 records out<br \/>\n536870912 bytes (537 MB) copied, 2.41354 s, 222 MB\/s<\/i><\/p>\n<p>Now we have created a file <i>\/home\/sandy\/extraswap<\/i> of size 512M which we will be using as a swap partition. Swap can be created by issuing <i><b>mksw<\/b><\/i><i><b>a<\/b><\/i><i><b>p<\/b><\/i> command<br \/>\n<i>$mkswap \/home\/sandy\/extraswap<br \/>\nSetting up swapspace version 1, size = 524284 KiB<br \/>\nno label, UUID=685ac04a-ad31-48a8-83df-9ffa3dbc6982<\/i><\/p>\n<p>Finally we have to run swapon command on our newly created swap partition to bring it into the game<br \/>\n<i>$swapon -s<br \/>\nFilename\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 Type\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 Size\u00a0\u00a0\u00a0 Used\u00a0\u00a0\u00a0 Priority<br \/>\n\/dev\/sda5\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 partition\u00a0\u00a0\u00a0 8130556\u00a0\u00a0\u00a0 46248\u00a0\u00a0\u00a0 -1<br \/>\n$swapon \/home\/sandy\/extraswap<br \/>\n$swapon -s<br \/>\nFilename\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 Type\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 Size\u00a0\u00a0\u00a0 Used\u00a0\u00a0\u00a0 Priority<br \/>\n\/dev\/sda5\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 partition\u00a0\u00a0\u00a0 8130556\u00a0\u00a0\u00a0 46248\u00a0\u00a0\u00a0 -1<br \/>\n\/home\/sandy\/extraswap\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 file\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 524284\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0 -2<\/i><\/p>\n<p>As you can notice when we first executed the <i>swapon -s<\/i> command at that time swap partition was not in the picture, once we executed the command <i>swapon \/home\/sandy\/extraswap<\/i>\u00a0 the swap partition was available.<\/p>\n<p>One last thing that we have to do is to add the entry of this swap partition in our <a href=\"http:\/\/en.wikipedia.org\/wiki\/Fstab\" target=\"_blank\" rel=\"noopener\"><i><b>\/etc\/fstab<\/b><\/i><\/a> file as with the next system boot the swap partition will not be active by default we have to do the entry of this swap in our \/etc\/fstab file.<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes you feel constrained due to the the RAM limit of your system especially when you are running heavy duty software\u2019s, in this blog I&#8217;ll talk about how you can overcome this problem by hav\u200cing an extra swap space to give you extra computing power First of all you can execute swapon command to check &hellip; <a href=\"https:\/\/opstree.com\/blog\/2013\/10\/30\/how-to-create-an-extra-swap-space-using-file-system\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to create an extra swap space using file system&#8221;<\/span><\/a><\/p>\n","protected":false},"author":171775670,"featured_media":29900,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[28070474,610],"tags":[768739285,28382],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/opstree.com\/blog\/wp-content\/uploads\/2025\/11\/DevSecOps-1.jpg","jetpack_likes_enabled":true,"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pfDBOm-6Y","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/posts\/432"}],"collection":[{"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/users\/171775670"}],"replies":[{"embeddable":true,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/comments?post=432"}],"version-history":[{"count":3,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/posts\/432\/revisions"}],"predecessor-version":[{"id":30309,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/posts\/432\/revisions\/30309"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/media\/29900"}],"wp:attachment":[{"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/media?parent=432"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/categories?post=432"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/tags?post=432"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}