{"id":6246,"date":"2025-03-22T22:12:34","date_gmt":"2025-03-22T21:12:34","guid":{"rendered":"https:\/\/roccadomenico.it\/wordpress\/?p=6246"},"modified":"2025-03-22T22:25:42","modified_gmt":"2025-03-22T21:25:42","slug":"increase-swap-size-on-ubuntu","status":"publish","type":"post","link":"https:\/\/roccadomenico.it\/wordpress\/increase-swap-size-on-ubuntu\/","title":{"rendered":"Increase swap size on Ubuntu"},"content":{"rendered":"\n<p><strong><em>This tutorial assumes that you are using swap file on your system, not a swap partition.<\/em><\/strong><\/p>\n\n\n\n<p>Now, let\u2019s see how to increase the swap file. First thing first, make sure that you have a swap file in your system.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>swapon --show<\/code><\/pre>\n\n\n\n<p>It will show the current swap available. If you see the type file, it indicates that you are using a swap file.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>swapon --show\nNAME      TYPE SIZE USED PRIO\n\/swapfile file   2G   0B   -2<\/code><\/pre>\n\n\n\n<p>Now before you resize the swap file, you should turn the swap off. You should also make sure that you have enough free RAM available to take the data from swap file. Otherwise, create a temporary swap file.<\/p>\n\n\n\n<p>You can&nbsp;disable a given swap file&nbsp;using this command. The&nbsp;<strong><em>command doesn\u2019t produce any output and it may take a few minutes to complete<\/em><\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo swapoff \/swapfile<\/code><\/pre>\n\n\n\n<p>Now&nbsp;use the fallocate command in Linux&nbsp;to change the size of the swap file.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo fallocate -l 4G \/swapfile<\/code><\/pre>\n\n\n\n<p>Make sure that you mark this file as swap file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo mkswap \/swapfile<\/code><\/pre>\n\n\n\n<p>You should see an output like this where it warns you that old swap signature is being wiped out.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo mkswap \/swapfile\nmkswap: \/swapfile: warning: wiping old swap signature.\nSetting up swapspace version 1, size = 4 GiB (4294967296 bytes)\nno label, UUID=c50b27b0-a530-4dd0-9377-aa28eabf3957<\/code><\/pre>\n\n\n\n<p>Once you do that, enable the swap file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo swapon \/swapfile<\/code><\/pre>\n\n\n\n<p>That\u2019s it. You just increased the swap size in Ubuntu from 2 GB to 4 GB. You can&nbsp;check swap size&nbsp;using the&nbsp;free command&nbsp;or the&nbsp;<code>swapon --show<\/code>&nbsp;command.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>free -h\n              total        used        free      shared  buff\/cache   available\nMem:           7.7G        873M        5.8G        265M        1.0G        6.3G\nSwap:          4.0G          0B        4.0G<\/code><\/pre>\n\n\n\n<p>You see how easy it is to resize swap size thanks to the swap files. You didn\u2019t touch the partition, you didn\u2019t reboot the system. Everything was done on the fly. How cool is that!<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial assumes that you are using swap file on your system, not a swap partition. Now, let\u2019s see how to increase the swap file. First thing first, make sure that you have a swap file in your system. It will show the current swap available. If you see the type file, it indicates that [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"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":""},"categories":[30],"tags":[],"class_list":["post-6246","post","type-post","status-publish","format-standard","hentry","category-informatica"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/roccadomenico.it\/wordpress\/wp-json\/wp\/v2\/posts\/6246","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/roccadomenico.it\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/roccadomenico.it\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/roccadomenico.it\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/roccadomenico.it\/wordpress\/wp-json\/wp\/v2\/comments?post=6246"}],"version-history":[{"count":2,"href":"https:\/\/roccadomenico.it\/wordpress\/wp-json\/wp\/v2\/posts\/6246\/revisions"}],"predecessor-version":[{"id":6249,"href":"https:\/\/roccadomenico.it\/wordpress\/wp-json\/wp\/v2\/posts\/6246\/revisions\/6249"}],"wp:attachment":[{"href":"https:\/\/roccadomenico.it\/wordpress\/wp-json\/wp\/v2\/media?parent=6246"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/roccadomenico.it\/wordpress\/wp-json\/wp\/v2\/categories?post=6246"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/roccadomenico.it\/wordpress\/wp-json\/wp\/v2\/tags?post=6246"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}