Which swap option do you use?

Hey guys

Which swap option do you use and why? Which one should you pick?

Option 1)

  • Swap partition

Option 2)

  • Swap file

Option 3)

Option 4)

  • no swap

in terminal when you execute $ swapon you can see your current swap status

Personally I use systemd-swap because it just takes what it needs and there are extra tuning options like in /etc/systemd/swap.conf.d/myswap.conf:
zswap_enabled=1
zram_enabled=1
swapfc_enabled=1

But maybe experts here have arguments that systemd-swap is not so good in certain situations?

3 Likes

I am using option 1: swap partition.
:slightly_smiling_face:

2 Likes

Awesome! I think this is the most common and the most robust option.

@whatthe, I use swap file because it is much easier to handle (increase, decrease, delete, re-create) than swap partition.

Just a regular swapfile setup here.

$ swapon
NAME      TYPE SIZE USED PRIO
/swapfile file 7.8G   0B   -2
$ grep swapfile /etc/fstab
/swapfile       	none      	swap      	defaults,pri=-2	0 0

systemd-swap is fine too.
In my case … I want swap used as little as possible … but want to make sure it has a decent pool to pull from if needed. So its at equal to my RAM and low priority and then I dont have any other services or worry about it.

(I have dozens of FF tabs open, telegram, some terminals, etc … so my RAM use is ~50% and my swap isnt being touched … which is what I want.)

1 Like

No swap : i very rarely fill my 16GB of RAM.

1 Like

I have a computer with 32GB RAM.
Since I am using this computer, swap was never used.

1 Like

I have 8GB RAM, so I use dynamic swap file plus zswap and zram. It’s an automated solution that I love, because since I set it, there are no more perma-freezes because of RAM depletion. It works great on SSD, because swap is almost as good as RAM and new allocation of space is done quickly in the background, without any noticeable bad effects.

You should never ever use zram & zswap at the same time.

3 Likes

I use a swapfile, currently 4 GB on most of my machines.
It is easier to handle. If I want to change the size, create a new one or delete one, I can simply do this while the system is running, without booting in a live system to resize partitions.
For me the best option so far, using this setup for some years now.

A good question is: what happens with a default installation of the OS? I happened to install on a laptop, I5, 8GB mem. and an SSD a few months ago and… there is no swap. Thanks to your suggestion I installed a swap file but then again it depends on your usage and of course you never know but the idea of swap dates from a time where memory was a problem like 512 MB or even less. Never forget that 512 KB was a lot in 1990, the year Linus started. So I guess swap will become obsolete in the years to come, there will be ample resources.

thanks, I actually did this lol
thought it would be extra fast but I guess I was wrong.

Personally I am a big fan of systemd-swap, I think it’s better than if you just use a simple swapfile.
I also think it is superior to a swap partition and superior to noswap at all.

I always use swap partitions. It’s what I’ve done since my time with Windows and this setup works for me. I prefer to have disk space pre-allocated for swap and a few other things on my systems.

I have a swap partition of 4Gb and I let systemd-swap (zswap) take care of it. Don`t know if this is right, but is working and almost is not used.

3x 4GB partitions striped across 3 SSDs for a total of 12GB swap, and 16GB ram.

Anyone ever used a swap partition and a swapfile at the same time?

no, but I dont see why you couldnt in so far as you are OK having multiple swap.
(also note priorities of each swap mount if useful)

That’s what I was thinking, just popped into my head and was wondering if anyone had tried it. :slight_smile:

12gb RAM which almost always gets full, using systemd-swap.

Only 8GB here (max on this system unfortunately) and it’s usually heavily loaded. The browser is the biggest memory hog, in particular when viewing YouTube videos, but I always have watch -n5 free -h running on one of the Terminal tabs to keep an eye on things & restart the browser when necessary, esp. when I’m running virtual machines.

I have a 10GB swap partition & performance starts to suffer when it gets around half full, which is to be expected.

Because my system has 32GiB RAM, i’m not using any physical swap at all.
I make use of Improved zramswap for an in-memory swap…