Maui Forums

Full Version: Its good iddea add swap in SSD?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,
In the past, with 8 GB of RAM and a mechanical hard drive, I don't add a swap.
I read in the last days that, the new kernel 4.11 are optimized for SSD (and swap in SSD) and this, open in me a question or doubt.
A computer, for example, with 8 GB RAM, with SSD, its good iddea add swap?

Always, I was think that, with 4, 8 or more RAM and with mechanic hard drive, not, not good iddea add swap (in my lasts years I don't use swap) but yesterday, I was read the article of new kernel with optimization for SSD....and generate a doubt about this...

Regards!
I don't add real swap for years here now on my hardware. I just use zram for compressed swap in RAM which is still faster as Swap on a SSD.

You need more RAM occasionally when compiling heavy projects like Firefox, Chromium or LibreOffice. If you do heavy video editing (4k video editing) it might exceed the memory available and needs to use swap.
Swap is also used sometimes if you just start a lot of applications and don't tend to close them and just use standby to ram also so you don't turn off your laptop/pc basically. This might then also end up eating RAM.
For everything else day to day you might not need swap but I personally recommend you to just install the package zram-config just in case so that if you exceed RAM usage it will at least have something to swap to Smile
Hello.
Yes, I also that, I don't add real swap for a years.
But yesterday, when I read the article for new kernel, this article generate in me a doubt about this..

Generally, I don't close my navigator also not close TB, not compiling, but yes, I editing video and audio, and never, turn off my pc, always, stand by.
In some times, I view in Info Center that, my available memory are 2 o 3%, after a some works or time, up to 10-15-20%.
In this moment I have 8 GB RAM but I think in add other 8GB, in total, 16GB.
In some times (only, 3, 4 or 5 times) when editing video and I was configured for preview audio (in kdenlive) my memory available was to 0, and I can't open other application.
After search about this I view that, the pluggin in kdenlive for preview audio consume a lot off memory, I disabled this option.

And thank you very much for indicate zram-config, I ignored this option entirely, I go to search info about this for install and config Smile

Thank you very much!
(8th May 2017, 11:09)leszek Wrote: [ -> ]... I personally recommend you to just install the package zram-config just in case so that if you exceed RAM usage it will at least have something to swap to Smile

This fascinated me; i did not know of this package. I've now researched it, then tested it in my 2 Maui VMs, to help me decide if i will take the plunge to actually install it into my real Mauis in Lappy & Tower [& maybe also then use gparted & fstab to remove my existing Swap partitions]. The VM results seem remarkable:

System [VB VM]
Base Memory 4096
Processor(s) 2

[attachment=1257]
[attachment=1258]

Code:
kdemeoz@Maui-VM:~$ cat /proc/swaps
Filename                                Type            Size    Used    Priority
/dev/sda2                               partition       2097148 0       -1
/dev/zram0                              partition       1011520 0       5
/dev/zram1                              partition       1011520 0       5


All that looks great, but i have one question: does zram in any way conflict with / steal memory from tmpfs [in which as you can see i run /tmp; pls note -- all the following is from my VM, but i do use a similar arrangement in my real Mauis]:
Code:
kdemeoz@Maui-VM:~$ df -h
Filesystem       Size  Used Avail Use% Mounted on
udev             2.0G     0  2.0G   0% /dev
tmpfs            396M  6.3M  389M   2% /run
/dev/sda1         17G   12G  4.0G  76% /
tmpfs            2.0G  160K  2.0G   1% /dev/shm
tmpfs            5.0M  4.0K  5.0M   1% /run/lock
tmpfs            2.0G     0  2.0G   0% /sys/fs/cgroup
tmpfs            2.0G  8.0K  2.0G   1% /tmp
/dev/sda3        8.8G  7.2G  1.1G  87% /home
VM_Share_Folder  168G   39G  130G  23% /media/sf_VM_Share_Folder
temp_(Seagate)   1.8T  755G  1.1T  43% /media/sf_temp_(Seagate)
tmpfs            396M     0  396M   0% /run/user/118
tmpfs            396M   12K  396M   1% /run/user/1000
kdemeoz@Maui-VM:~$
Just to add my 2 cents Wink Adding swap on an SSD disk is not really a good option, since SSD has a limited amount of writes possible. Therefore, if you use an SSD for a swap and the system swaps a lot, I think it will destroy the SSD in a short time.
(9th May 2017, 16:44)rocky7x Wrote: [ -> ]Just to add my 2 cents Wink Adding swap on an SSD disk is not really a good option, since SSD has a limited amount of writes possible. Therefore, if you use an SSD for a swap and the system swaps a lot, I think it will destroy the SSD in a short time.

Agree - hence i deliberately put my Swap partition on my HDD not my SSD when i setup my Tower.

However, correct me if i'm mistaken, but that [good] advice only pertains to a physical Swap partition, doesn't it? My [new] interest, having learned of it from leszek's cool info, is now zram - which i thought i understood runs in RAM somehow [?], in which case the "traditional" Swap writes-caution doesn't apply...?

Having searched online for "zram vs tmpfs", i still have no clear answer, hence i still don't really understand if they coexist correctly, or would cause me problems. Whilst the following will seem crude, here is a basic idea of why i'm confused.

1. tmpfs occupies RAM
2. zram occupies RAM [albeit compressed]
3. Swap partition exists on a physical drive, & exists for data transfer once RAM is all consumed
4. If RAM space is consumed not only by the usual instantaneous working data, but also by tmpfs, & maybe also now by zram, then arithmetically there is now less free RAM available for newer working data... which ironically then increases the chance of Swap space being needed. 
5. If that Swap is the traditional physical partition, then of course system responsivity decreases, but nothing catastrophic will occur.
6. Conversely if there is no physical Swap partition, but "only" zram, the system attempts to swap working data into this, but given this IS in RAM, & swapping is ONLY needed when RAM is low or exhausted... well, how can this work? Isn't this kinda like the old joke about trying to lift yourself off the ground by your shoelaces?
7. Additionally, how do zram & tmpfs negotiate with each other to decide "who" will get to grab the specific working data that the kernel is trying to swap out? If they "argue" instead of "cooperate", then surely "bad things" will result?

As you can see, i still don't understand.
tmpfs does not conflict with zram.
Thank you.