0

~$ sudo swapon --show gives me this

NAME      TYPE      SIZE USED PRIO
/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 -

NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
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?

o4385630
  • 1
  • 3
  • 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. – doneal24 Dec 18 '18 at 23:21

1 Answers1

0

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:

https://support.rackspace.com/how-to/create-a-linux-swap-file/

(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.

thomasrutter
  • 36,774