This question already has an answer here:

~$ sudo swapon --show gives me this

/dev/sda5 partition 976M   0B   -2

I want to increase my swap size. Is there a way to increase this or do I have to create a new partition or a file? I have gparted installed and I see that there are only 2 partitions as lsblk shows below -

sr0     11:0    1  1024M  0 rom  
sda      8:0    0 238.5G  0 disk 
├─sda5   8:5    0   976M  0 part [SWAP]
└─sda1   8:1    0 237.5G  0 part /

How do I go about increasing the size?

marked as duplicate by user68186, pomsky, Sergiy Kolodyazhnyy, Fabby, guiverc Dec 18 '18 at 23:54

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Just an observation, not a answer, but if you're actually using that much swap space then your performance is going to be terrible. I'd strongly suggest increasing the amount of physical memory in the system. – Doug O'Neal Dec 18 '18 at 23:21

If you don't want to re-partition you can use a swap file. It works like it does on Windows. Instead of specifying a partition name in your fstab, you specify a file, say, in your root partition.

You will need to initialise the file simply by creating a file containing zeros of your desired size, and make it readable only by root. Also (I can't remember if this is necessary) format it with:

sudo mkswap /myswapfile

Here are some full instructions:


(It's strange they chose to put it in /mnt, that's not what /mnt is)

You can use the swap file in addition to your existing swap partition, and there should not be a performance hit. You can even specify a priority in your fstab for what order they should be used, which is for when some of your swap is on a faster device, but that's not really relevant here.

Not the answer you're looking for? Browse other questions tagged or ask your own question.