With or without swap

[list=]hi
I have 6Gb of ram i was thinking what if i go without a swap memory does this is a good idea. Does this effect the performance or will it creates system destabilize the system

You’ll probably encounter a lot of different opinions on that one … e.g. this video strongly recommends using swap due to some software that expects it and will not be stable without it, but personally I have not encountered any case where swap was really needed if you otherwise have enough RAM.
Currently I run Ubuntu MATE 16.04 with 8 GB RAM swap-less, and haven’t had any issues.
One thing you definitely do give up if you decide to go without a swap partition is the ability to suspend to disk, which is probably more of an issue for portable machines than desktops.

3 Likes

Hi @Rasitha,

even with a large amount of RAM; you should at least have 1GB swap for that just in case scenario!. (Just my opinion!). :smiley:

With most if not all Linux systems 2GB swap is recommended and I would not install a distribution with out one. If you choose not to add a swap partition you may run into trouble

2 Likes

Hi

i just recently went from 14.04 to 16.04 with clean install with that i made a little research on this topic i have 16GB ram and I run 14.04 was without swap there I had some difficulties when VM was running now on 16.04 i have 4 GB SWAP no problem on VM’s

1 Like

I’ve 6gb of RAM, and just have a swap file instead of a swap partition… although the swap file has never been used by any application. The reason I prefer a swap file is to make it easier to clone installations - I use Timeshift to clone my complete (including the swap file) installation to other Laptops/Desktops… I only ever install one OS, my other boxes use clones of it (and I have USB drives with the cloned OS too). Linux doesn’t work like Windows, so unless you use/need proprietary drivers for the clone target, all hardware is detected during each boot.

For those interested, here’s how to set up a 2gb swap file:

("/swapfile" is the path/name of the swap file, and ā€œ2097152ā€ is the size in kilobytes (i.e. 2GB).)

dd if=/dev/zero of=/swapfile bs=1024 count=2097152

(Prepare the swap file)

mkswap /swapfile

Mount it

swapon /swapfile

Finally, add the following to /etc/fstab

/swapfile       none    swap    sw      0       0

Reboot and you have a 2gb swap file.

4 Likes

I’ve been running without swap on my 4GB RAM laptop for a ā€˜very’ long time. With no adverse side-affects. Many people say to use swap because of ā€˜better safe than sorry’ attitudes, but really if you have more than 6GB RAM, better not to use swap, on a consumer computer it’ll be wasted space.

It’s more useful to think to yourself ā€œdo I ever use more than 4GB in my day-day computing?ā€ if no, then you won’t ever use the swap.

Pros:

  • System won’t totally crash if out of memory.
  • System is more efficient when using the memory as cache.
    • Good for low-RAM systems.
    • Particularly the case with large file transfers.

Cons:

  • Reserves a bit of hard disk space (swap partition or file)
  • System degrades performance if the system swaps a lot on a mechanical HDD.

I have 16 GB of RAM, with a 2 GB swap at the end of my data drive. It’s there if :penguin: needs it.

In most cases, it’s hardly ever used, but it’s available if memory management decides to be slightly more efficient by swapping, like:

  • Copying large files, files are cached in RAM - if there’s unused background programs, they would temporarily move to swap.
  • Running out of memory (for me, unlikely :grin:), then swap prevents the system from freezing up.

I also use my RAM as a RAM disk (at /tmp) for temporary files, so if I go over the limits, swap provides a bit of breathing space. :slight_smile:


So if it was under 4 GB of RAM, I’d definitely keep swap. If it’s over 4 GB, then it’s up to you and whether you’ll use all your RAM for your computing applications. :thumbsup:

2 Likes

Swap is used for sleep and hibernate, and as a safety factor is one of your applications runs out of memory.
An example - your edit a rather long video track and add a music track along with a narration track

If you don't sleep or hibernate you system I suggest using a small amount of swap ... really won't slow your system down when not being used and is a good safetey net

1 Like

Desktop:
24G ram
2G swap
Swappiness=0
The swap never kicks in.

Laptop:
4G ram
4G swap
Swappiness=0
Cache_pressure=60
Swap very very rarely kicks in with the added settings.

Is this a laptop? You may want to hibernate and then your swap partition needs to be the size (6G) of your ram. And these days 6G of space on a HDD is no big deal.

2 Likes

I for one never sleep or hibernate, any of my machines I’m on them to much for this action but some people feel the need for this although I did test the suspend mode and my machine did not we up

1 Like

Hi guys. I have Ubuntu mate in my computer with 1 GB of swap, 4 GB of RAM, doing well and not if you use it in any APP, but I also have Ubuntu Mate installed in a micro sd card, this will have no swap, works very well and it has only failed me once when UM was suspended, refused to restart, then I canceled the suspension. It is my Ubuntu Mate laptop, I put it on any computer and have my private things, someday tell you how an installation is done on a micro sd, greetings …

1 Like