SSD for swap only on low mem machines!

Here you can post about your various experiences with PC hardware. You can also post about hardware that is not compatible with the linux kernel or not recommended for use with Porteus.
nanZor
Shogun
Shogun
Posts: 381
Joined: 09 Apr 2019, 03:27
Distribution: Porteus 5.01 x86-64 LXQT

SSD for swap only on low mem machines!

Post#1 by nanZor » 10 Nov 2023, 09:51

Browsing the onboard Porteus faq from many years ago, I got a great idea! With the passage of time, many of my little computers have cheap ssd's inside rather than the spinning rust of hard drives.

Here is the location of the html faq on your system where I got the swap idea from you can easily hit up with your browser:
file:///usr/doc/Porteus-FAQ/index.html

Instead of doing a frugal install to the ssd's, I prefer to boot and run from a good quality USB stick. However, instead of using swap from my usb stick, the cheap ssd's are faster! Why not put swap there and not on my stick! (as long as I'm willing to have that drive mounted of course - but it's just a swap file, so no biggie)

Also possible: If you have a stash of slower speed usb sticks, but invest in just one really fast usb stick, perhaps you can dedicate that to being solely a swap drive to simply thrash while you have 10 tabs open. :)

I think you get the idea, albeit this is a late-night hack and perhaps too much coffee!
That's a UNIX book - cool. -Garth

nanZor
Shogun
Shogun
Posts: 381
Joined: 09 Apr 2019, 03:27
Distribution: Porteus 5.01 x86-64 LXQT

SSD for swap only on low mem machines!

Post#2 by nanZor » 11 Nov 2023, 05:31

Tip: If you do dedicate a stick just to hold a swapfile, don't forget to format it with a filesystem that can handle permissions like EXT2 - I forgot to do this and used an out of box fat32, and while that worked, Porteus dutifully balked at file permissions and ownership.

vm.swappiness value? the default is 60. Many "recipes" for tuning this are all over, but I'm going to just leave it as is unless I'm convinced I need to tweak it according to my workload.

Contrary to most web advice, a dev for Linux CGROUP V2 has what seems like very good information. (Put your coffee pot on) SSD's? vm.swappiness=100 might do just fine. Usb sticks - maybe 60 is just fine.

https://chrisdown.name/2018/01/02/in-de ... -swap.html

Interesting!
That's a UNIX book - cool. -Garth

User avatar
M. Eerie
Moderator
Moderator
Posts: 622
Joined: 31 Aug 2017, 21:18
Distribution: Nemesis Xfce/MATE x64

SSD for swap only on low mem machines!

Post#3 by M. Eerie » 11 Nov 2023, 09:09

Hi nanZor.

Just found the link to an article I recently read, referring to the convenience of using zram because of the better performance it offers when using SSD's.
> Does not compute_ 🖖

https://forum.porteus.org/viewtopic.php?p=94310#p94310
https://forum.porteus.org/viewtopic.php?p=84002#p84002
https://forum.porteus.org/viewtopic.php?p=77174#p77174
https://forum.porteus.org/viewtopic.php?f=39&t=8584

nanZor
Shogun
Shogun
Posts: 381
Joined: 09 Apr 2019, 03:27
Distribution: Porteus 5.01 x86-64 LXQT

SSD for swap only on low mem machines!

Post#4 by nanZor » 12 Nov 2023, 06:58

Oh, that's an interesting article about zram for swap, I'll need to digest it further. Piqued my interest for sure.

I think Chris Down's article got me past the antique way of thinking about swap as just "slow extra ram". And the vm.swappiness knob being turned all over the place without taking the workload into account - and a bad metric for measuring the performance gain/loss. My take is that being hardware dependent with speed, a hard drive might need a value lower like 25 than the default 60 that most Linux default to, whereas an SSD 90/100 being ok. I guess it's really more about reclaimed pages and whatnot referred to in the article and the video.

In the article you referenced, it would be interesting to see what those distros that do enable zram swap have a vm.swappiness value fine tuned for. Thanks for sharing that.
That's a UNIX book - cool. -Garth

rych
Warlord
Warlord
Posts: 622
Joined: 04 Jan 2014, 04:27
Distribution: Porteus 5.0 x64 OpenBox
Location: NZ
Contact:

SSD for swap only on low mem machines!

Post#5 by rych » 13 Nov 2023, 09:21

nanZor,
We've had a little discussion about swap here: Swap priority during boot (Post by rych #95612). Admittedly I never had to make a swap partition/file because there is always 8 or 16GB RAM on the standard computers these days -- I never run out of RAM. Do you?
nanZor wrote:
10 Nov 2023, 09:51
instead of using swap from my usb stick, the cheap ssd's are faster!
These days you can use a fast SSD inside a fast USB enclosure connected to a fast USB port, see Booting from NVMe USB enclosure

However, the system SSD is still faster. It's normally under Windows and is therefore carries NTFS, and you can't or don't want to make new partitions on the host system disk. I've recently switched to the new ntfs3 mounting, and the speeds of working with NTFS from Porteus have greatly improved, see NTFS3 Kernel Module (Post by rych #97030)

So. I suggest a swap file not a partition on the system SSD NTFS if you really need a swap.

Rapha_
Shogun
Shogun
Posts: 238
Joined: 12 Jun 2021, 21:59
Distribution: Xfce 4.12 - 5.rc3 - x86_64
Location: France

SSD for swap only on low mem machines!

Post#6 by Rapha_ » 14 Nov 2023, 00:54

about zram,

it's available in Porteus-v5.0, v5.01 / OV.Porteus / APorteus / Nemesis / Porteux

The Cheatcode is the same :
the zram=some_value%

... enable the use of zram, which is a compressed block device
inside your RAM that acts as a swap partition. Zram operates
faster than using swap on a hard drive and creates more
(virtual) memory than using RAM alone because the data inside
is compressed. This will provide a performance boost on
systems with low RAM, but it uses more processor cycles (to
compress and decompress the data) than regular swap.
Example: 'zram=33%' will set aside 33% of your RAM as a zram
device.
Not tested ...

nanZor
Shogun
Shogun
Posts: 381
Joined: 09 Apr 2019, 03:27
Distribution: Porteus 5.01 x86-64 LXQT

SSD for swap only on low mem machines!

Post#7 by nanZor » 14 Nov 2023, 09:07

rych wrote:
13 Nov 2023, 09:21
nanZor,
... -- I never run out of RAM. Do you?
Well, that's the thing. I've never seen it with the conventional top utils, but wonder about spikes like having a bunch of tabs open, and a link that brings up a LibreOffice .doc file, that kind of thing that lxde task manager can't catch etc.

So this adventure into swap is just kind of a learning project. Learned that these days, swap partitions are not necessary since swap *files* are just as good and certainly more manageable. Also interesting is that default installs of other flavors of Linux will put a *dinky* one by today's standard, like 512mb which conventional wisdom says is too small. Is it that small just to handle spikes for a richer, more flavorable experience? :)

Even in the Porteus faq, the author details just a dinky 512mb swap file if you want one. Which is in line with other distro's..

So it just got me wondering and learning about the history of Linux swap from an earlier era perspective, vs today. Still evaluating whether it is a benefit.

One thing that Chris Down's mentions that they avoid is that it is futile to spend 10% of your existing resources, to only get 10% back with swap! So interesting, but not religious about it. In a data centre maybe..
That's a UNIX book - cool. -Garth

rych
Warlord
Warlord
Posts: 622
Joined: 04 Jan 2014, 04:27
Distribution: Porteus 5.0 x64 OpenBox
Location: NZ
Contact:

SSD for swap only on low mem machines!

Post#8 by rych » 14 Nov 2023, 09:43

nanZor wrote:
14 Nov 2023, 09:07
the history of Linux swap
I was too late to that party: when I started using Porteus in 2014 -- the smallest RAM was already 4GB on any computer around. I didn't seem to have exhausted even the 4GB back then under Porteus and didn't set up any swap (unlike Windows of course). Then all the machines including home one got upgraded to 8-16-32Gb of RAM. Even though I'm a heavier Linux user now, I just can't catch up filling up that much RAM. I'd be intrigued to see any symptoms of running out of RAM and then I'd think about swap. Perhaps I could find an old computer with 4GB or 2GB -- but those would be so old and slow in every way, that I wouldn't even want to work on them, even though Porteus would boot and be operational -- why torture yourself with old junk.

So, I think swap is dead.

porteux
Samurai
Samurai
Posts: 175
Joined: 12 Mar 2023, 22:10
Distribution: PorteuX

SSD for swap only on low mem machines!

Post#9 by porteux » 19 Nov 2023, 16:07

@nanZor, the application top shipped with Slackware 15.0 (and therefore Porteus 5.xx) is too old and it doesn't inform the correct amount of RAM in use. I recommend using this command since it reads direct from the kernel:

Code: Select all

echo $(( ($(grep MemTotal /proc/meminfo | awk '{print $2}') - $(grep MemAvailable /proc/meminfo | awk '{print $2}')) / 1024 )) MB
BTW, I managed to boot PorteuX 0.8 LXDE in VirtualBox with just 250 MB of RAM :) Of course you can't do much with that, but it's a fun experiment anyway. Nowadays many applications use heavy browsers (usually Chromium) in the background, such as: WhatsApp, Telegram, VsCode, Etcher, etc. That's why the real RAM bottleneck is not the OS anymore.

rych
Warlord
Warlord
Posts: 622
Joined: 04 Jan 2014, 04:27
Distribution: Porteus 5.0 x64 OpenBox
Location: NZ
Contact:

SSD for swap only on low mem machines!

Post#10 by rych » 20 Nov 2023, 05:08

porteux wrote:
19 Nov 2023, 16:07
correct amount of RAM in use
Also I understand that the system can squeeze a little extra out of some reserves(?) or tmpfs mounts (?) if needed. Hence the difference between MemFree and MemAvailable? I don't have any swap, so was expecting MemFree=MemAvailable?

Code: Select all

grep Mem /proc/meminfo
MemTotal:       16178136 kB
MemFree:         7026248 kB
MemAvailable:   11691612 kB
porteux wrote:
19 Nov 2023, 16:07
I managed to boot PorteuX 0.8 LXDE in VirtualBox with just 250 MB of RAM
That's amazing. I'm running Porteus 5.01 OpenBox with lots of modules pre-activated, changes on EXIT so things are living in RAM, plus a heavy Firefox session running -- and a 4GB of RAM (MemTotal-MemAvailable) is in use already. I guess if I run something heavy on top, it might one days claim all my memory. But then again, such software usually has some built-in methods of swapping, like memory-mapped files, cache, scratch disk etc.

porteux
Samurai
Samurai
Posts: 175
Joined: 12 Mar 2023, 22:10
Distribution: PorteuX

SSD for swap only on low mem machines!

Post#11 by porteux » 20 Nov 2023, 10:55

@rych, according to proc documentation, MemAvailable is an estimate of how much memory is available for starting new applications, without swapping. While MemFree is the amount of memory that hasn't been used by the system at all. In other words, MemAvailable includes some chaching that can be released if the system needs to allocate more memory:

Code: Select all

MemAvailable = MemFree - low water mark + min(page cache/2 + low water mark) + some other reclaimable stuff
More information here: https://stackoverflow.com/questions/308 ... mavailable

In my tests, most of the task managers don't use MemAvailable to calculate the used memory, therefore they usually provide an optimistic (wrong) memory usage. Take lxtask (LXDE) and qps (LXQt), for instance (although they have been patched in PorteuX to fix that). And to be honest, I don't understand what GNOME's and KDE's system monitor do, but definitely something more complicated and unnecessary than they should -- as usual with these 2 desktop environments :teehee: Points to Xfce and MATE for doing it correctly.

User avatar
Rava
Contributor
Contributor
Posts: 5416
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

SSD for swap only on low mem machines!

Post#12 by Rava » 30 Nov 2023, 05:45

nanZor wrote:
11 Nov 2023, 05:31
Tip: If you do dedicate a stick just to hold a swapfile, don't forget to format it with a filesystem that can handle permissions like EXT2
When you want to use a certain whole drive or at least a certain whole partition solely for swap, why use a swap file on it?
Is a swap partition not much more performant (="offers good performance")?
Cheers!
Yours Rava

rych
Warlord
Warlord
Posts: 622
Joined: 04 Jan 2014, 04:27
Distribution: Porteus 5.0 x64 OpenBox
Location: NZ
Contact:

SSD for swap only on low mem machines!

Post#13 by rych » 03 Feb 2024, 01:53

As I'm now forced to boot into some 4GB RAM machines, I see this sad picture after booting with changes in memory to be saved on exit, and using Firefox only:

Code: Select all

root@porteus:~# grep Mem /proc/meminfo
MemTotal:        3939952 kB
MemFree:          558808 kB
MemAvailable:     801220 kB

Post Reply