Do i need swap?

While performing a clean install of manjaro xfce 20 i have selected swap : hibernate and it crashes.

I just wanna know is this alright to not create swap?
Do i need swap?

Some info:

1 TB HDD
8 GB RAM
NVIDIA 1050ti GPU
Intel i5 7th gen
Erase disk installation (full clean)

8 GB RAM = recommended 8 GB SWAP for safety.
With 16 GB RAM and more SWAP is useless (mostly scenario).
Hibernation is Windows thing. Does not work properly in Linux at all.

Your call.

1 Like

As always - it depends. Is it a laptop or desktop PC? For desktop hibernate makes no sense. Swap is useful if you operate lot’s of memory consuming programs in parallel or if you are compiling code or often install fresh AUR packages. If you don’t use hibernation than a swap file could be a good alternative as well. Be aware that the system performances drops dramatically when swap is used. So, if you are not a coder 4 GiB swap should be fine just to avoid crashes when running out of RAM. For this question you might get as many different answers as forum users enter this thread. :wink:

If you still want to use hibernation you need the resume kernel parameter set in /etc/default/grub and you need the resume HOOK /etc/mkinitcpio.conf.

https://wiki.archlinux.org/index.php/Power_management/Suspend_and_hibernate

2 Likes

I’d do the default Manjaro install and use a Swap file rather than a Swap partition. Agree about hibernation not needed.

1 Like

I have 32Gb RAM and when I initially setup the drive I created a 32Gb swap. It has never been used. And I do a lot of memory intensive work.

Ok, this is what I know…

When Linux was first written “640K is more memory than anyone will ever need”. So, now days 8Gb really is more than most systems need. Yes, there are exceptions to that rule, but most of them have to do with WinBlows.

The thing that Swap is mostly used for in Linux is, RAM dump on crash for debuging. Or save state on Hibernation, as others have noted.

The short answer now days is “No”. With the caveat emptor that if your system uses RAM dump or hibernation, then “Yes”… at about 2Gb disk for each 1Gb RAM.

1 Like

So when the system runs out of RAM, swap is not necessary used as a form of temporary RAM?

Put a swap on your system and log how often it’s used (assuming you don’t have RAM dump or hibernation).
If you have a bloated system… live wallpaper, widgets and doodads all over your desktop, 30 or 40 tabs/windows open at one time… yeah, your going to need RAM/swap, and lots of it.
Or you could run a cleaner distro/desktop interface. I still have systems around here with 4Gb of RAM, running Lubuntu, and hardly ever dig into swap. (admittedly I don’t play modern games on 4Gb, but I still do HTML5 games on Firefox and that’s know to have problems eating up RAM)

Even if you do run out of RAM, it will just bottleneck until some frees up, and that’s usually not much worse than the bog-down from swap.

P.S. Thanks for reading and understanding my whole post, not just pulling one line out and reading it out of context.

I think Manjaro is a popular os for Linux-gamers, in such a situation I think swap might be something such user needs even with 16GB with certain games. Anyway I should test this myself (I have a swap partition).

Even if you do run out of RAM, it will just bottleneck until some frees up, and that’s usually not much worse than the bog-down from swap.

I wonder if that still applies when using an ssd.

I did a test a few months back…bored as hades.

First, even outside of this test, I have all my compiling set up to use /tmp.

The time it took to complete this test was irrelevant…the purpose was to fill 32GB of RAM and crash the system.

Firefox…20 tabs.

Put my entire $HOME/.cache in RAM (using ASD)

Compile linux 5.8.0RC1 simultaneously with:

glibc 2.31 and

gcc 10.1

At no point did I exceed 27GB.

So, for my daily use, swap [file,partition] is unnecessary/unneeded.

Sure, but probably not as pronounced as when swap is on a spinner. It still takes time to do the actual work.

Hi !
I ALWAYS setup swap, whichever RAM size. even with an aggressive swappiness, attempting to maximize RAM use, I see suff in my swap.
Here an exemple with a long session, 3 Firefox profiles with lots of tabs, Gimp, Shortwave & pulseeffect :

[meuh@ordi1 ~]$ free
              total       utilisé      libre     partagé tamp/cache   disponible
Mem:          11756        4772        3987         574        2996        6099
Partition d'Ă©change:         255          60         195
[meuh@ordi1 ~]$ 

But, as I don’t know if it’ll be used and what size I should set, I use systemd-swap.
To optimize it, I create a file : /etc/systemd/swap.conf.d/overrides.conf
Where I add to default setup :

swapfc_enabled=1
swapfc_min_count=1
swapfc_chunk_size=512M

In short, it creates a first 512Mo temp swapfile that can be complemented by as many other as needed.

My setup : Sujet: Optimiser la gestion de la RAM et du Swap sous Linux | l'Almanet doLys de nam1962 et ses amis (clic on the flag to have the english translation)

:wink:

4 Likes

To use Zswap you need a swap partition/file. Zswap - ArchWiki

What I do is using a swap file, and let it scale as needed.

I am still new in this. And now I am confused…what is the best solution than ?

To make swap partition during the installation or what ?

Use systemd-swap It’ll take care of itself as said on #4

There is rarely such a thing as the best solution. It always depends on what you want to do, then some solution can be helpful to achieve your goal. The same solution can become a hinderance in other cases.

1 Like

Interesting. I have 32 GB as well, with a 500 MB swap file. I do see some swap use from time to time in a ballpark of tens of megabytes, with swappiness set to 20. And I haven’t used the system for anything memory intensive since I installed Manjaro about three months ago :thinking:

Personally, I think swap needed when compiling from AUR or from source code.

https://pasteboard.co/Jnp5rUf.jpg

1 Like

Nothing special… I have 6 gb ram which is shared with graphics card…I just want smooth multitasking, browsing and gaming (only fm20). Most of the time while I am using chrome, few tabs opened, laptop slows