How can I get more swap space?

Linode Staff

I am in need of more swap space due to an application on my Linode. How can I go about increasing the swap disk on my Linode?

6 Replies

Hello there! There are actually a few different options that we have to increase the size of the swap on your Linode. It is important to note what swap is used for: Swap space is a reserved area that is utilized when your RAM has become full. If this is occurring frequently on your Linode, you might want to consider resizing to a plan with a larger amount of RAM, as utilizing swap can potentially slow down your machine, as transfer speeds from Solid State Drives are not quite at the speed as what RAM can handle.

Outside of resizing our Linode plan to utilize more RAM, we have two main options to increase our Linodes Swap Size: Resizing the Swap partition, and utilizing a Swap File. Generally speaking, using a Swap File is an easier process, as you can do it while the system is live and running, unlike resizing your swap partition.

Option one: Resizing the Swap Partition.

Our first step will be determining if it is safe to resize our swap partition. Assuming your Linode is set with our normal configurations, your swap disk size will be roughly 512MB, and the normal root disk will be taking up the rest of the space on your Linode plan. We are going to need to decrease the total allocated space on our root disk, and reallocate that space to our swap disk. Lets make sure that we have the adequate amount of space by running df -h on your Linode. This will output the amount of used space on your Linode, and will key us into how much space we have to allocate to our swap partition. For the rest of this post, we will pretend that we do have enough space, and we are planning on resizing our current 512MB swap disk to 1024MB. I will be preforming this from a fresh deployed CentOS 7 Linode.

Once we have determined that it is safe to proceed, we will need to power down our Linode. Once powered off, we will want to navigate to the Advanced tab in the cloud manager, then select the three option dots for our main disk, then select "Resize". We will want to figure out the difference in disk size for our resize that will free up our desired space. With that change in, we will now be able to select our swap disks size, and resize it to the new desired size. Once rebooted, you can now see your swap size by running swapon -s.

Option two: Swap Files

Swap files are a bit more robust, as you can add them as your system is live. They do require issuing more commands, but they give the flexibility of adding more swap space on the fly.

To start, we will need to allocate the space for swap. To add 512Mb, we will want to run the following command:

sudo fallocate -l 512M /swapfile

From here, we will want to make sure our permissions are set correctly, then we will need to create the swap file:

sudo chmod 600 /swapfile
sudo mkswap /swapfile

Then we will want to enable our Swap File with this command:

sudo swapon /swapfile

And lets make sure to add the following line to our /etc/fstab:

/swapfile swap swap defaults 0 0

Now we can run swapon -s , and it will return our current swap disk, as well as our new swap file!

This command:

sudo allocate -l 512M /swapfile

should actually be:

sudo fallocate -l 512M /swapfile

I found this article which might be of interest: [how to increase your swap file]: (

How do we get more swap space at the outset?

I created a new node today, but it would not let me specify partition sizes.

"No problem", I thought, "I'll blow away the wrongly sized partitions and create new ones."

But then when I chose "Rebuild", Linode's deployment scripts destroyed my carefully built partition table and reset them all to the default.

I destroyed the misconfigured node a few seconds later.

How do we deploy a Linux distribution and have it respect the existing partition table?

Hey @MattH,

Didn't see your update to this post. In these instances, I'd recommend deploying the image that you want, then resizing the disk manually. You may need to first resize the root disk to a slightly smaller amount, then expand the swap disk to what you were planning on using.

This was excellent, I don't want to upgrade yet to the next plan and this should let me limp on by. Worked great, can see the 8.5gb of SWAP I just added in htop!


Please enter an answer

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct