Increase swap

Hey!
I bought more ram for my pc and i am confused about how (and if) i should increase the swap on my system. I found a ton of different guides but am not sure which one to pick.

I upgraded from 16GB to 32GB of ram. Does the size of the swap file need to match the physical ram even if i am not using hybernate (i did not pick that option on startup).

Would be super cool if someone could link me a guide.
Thank you!

1 Like

Honestly I would just test it, see how it runs first my laptop barely touches the swap

2 Likes

No, if you are not using hibernation.

What is the current size of your swapfile?

2 Likes

Good questions, didn’t even think to ask them as I don’t use hibernate

2 Likes

@Buckfae, what do you do on your computer?

I have only 8gb RAM (some shared for integrated graphics) on my laptop and swap is only used when I run a VM with 3gb. Otherwise, I didn’t see swap is used, even when I open a lot of apps, like browsers, code editors, GIMP, Krita and KDEnlive (I’ve never checked if swap is used on video rendering… <— TODO).

My guess is that you don’t need more swap, Linux is not RAM eater as Windows.

1 Like

The size of the swap file grows as needed.
Swap partition size does not do it by itself.

1 Like

Then i think the best solution for me is to remove the partition and use a swap file instead?
Could you link a tutorial?

I’m doing Machine Learning research, some of my models tend to eat a LOT of RAM.

1 Like

If I were you, I would see if the current swap partition is sufficient for your use first.
Only if it is not, would I start to investigate https://wiki.archlinux.org/title/Swap

1 Like

This was new to me.
Is this valid in case one uses hibernation as well?

Let’s say, I create a swapfile of 512 MiB and want to use it as resume device on a system with 8 GB ram.

Okay, thank you.

2 Likes

As an alternative to creating an entire partition, a swap file offers the ability to vary its size on-the-fly, and is more easily removed altogether. This may be especially desirable if disk space is at a premium (e.g. a modestly-sized SSD). https://wiki.archlinux.org/title/Swap#Swap_file

I don’t use it myself but as far as I know:
Arch wiki

2 Likes

I am not sure if that means

just by itself. Perhaps I misunderstood what you wrote.

As far as i know, the procedure for resizing the swap is first to disable it (swapoff) and then use dd to resize it. There are however, if I remember correctly, some pieces of software to manage it dynamically.

Edit:

This is what I remembered that I had come across before for managing the size of the swapfile dynamically:

1 Like

Ouh sh#t. You are right!
It’s been a long time since I had a swap file in use.
My bad, again. :neutral_face:

1 Like

Whether you need swap or not depends or course what you are doing with the machine.

I also have 32GB RAM and run several 8GB RAM VirtualBox virtual machines, each one is running EndeavourOS or Arch, all at the same time. So far I have never needed swap on this 32GB RAM machine, and also never in the 8GB RAM virtual machines.
So I don’t have any swap partition nor swap file.
So far so good.

What kind of programs are you planning to run on the machine?

If you do not use hibernation you could even go for no swap.

If you hibernate you want to have as much swap as RAM. A little less may work as well because the RAM gets compressed when hibernated to disc.

I recommend a swapfile. Get rid of the swap partition and grow your root to consume the extra space. Then create a swapfile and use that.

I would suggest to look into zram just in case.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.